From 21ca1d35e60fbe2737ec68919028b4a31935ea0d Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 23 Oct 2024 16:30:50 +1300 Subject: [PATCH] Generate indices.get Signed-off-by: Thomas Farr --- UPGRADING.md | 8 +- .../opensearch/OpenSearchAsyncClientBase.java | 5 + .../opensearch/OpenSearchClientBase.java | 5 + .../opensearch/_types/ExpandWildcard.java | 26 +- .../opensearch/_types/mapping/AllField.java | 66 ++-- .../_types/mapping/DataStreamTimestamp.java | 148 +++++++++ .../_types/mapping/DynamicMapping.java | 18 +- .../_types/mapping/DynamicTemplate.java | 65 ++-- .../_types/mapping/FieldNamesField.java | 32 +- .../opensearch/_types/mapping/IndexField.java | 32 +- .../opensearch/_types/mapping/MatchType.java | 12 +- .../_types/mapping/RoutingField.java | 32 +- .../opensearch/_types/mapping/SizeField.java | 32 +- .../_types/mapping/SourceField.java | 107 +++++-- .../_types/mapping/SourceFieldMode.java | 65 ++++ .../_types/mapping/TypeMapping.java | 299 ++++++++++-------- .../client/opensearch/indices/Alias.java | 75 +++-- .../opensearch/indices/GetIndexRequest.java | 268 +++++++++------- .../opensearch/indices/GetIndexResponse.java | 17 +- .../client/opensearch/indices/IndexState.java | 187 ++++++----- .../OpenSearchIndicesAsyncClientBase.java | 79 +++++ .../indices/OpenSearchIndicesClientBase.java | 78 +++++ .../opensearch/OpenSearchAsyncClient.java | 5 - .../client/opensearch/OpenSearchClient.java | 5 - .../indices/OpenSearchIndicesAsyncClient.java | 35 +- .../indices/OpenSearchIndicesClient.java | 35 +- .../client/opensearch/model/EnumTest.java | 4 +- .../client/codegen/CodeGenerator.java | 1 + .../client/codegen/model/EnumShape.java | 21 +- .../client/codegen/model/ObjectShape.java | 13 + .../client/codegen/model/SpecTransformer.java | 145 ++++++--- .../codegen/model/TaggedUnionShape.java | 13 +- .../client/codegen/model/Types.java | 1 + .../codegen/model/overrides/Overrides.java | 26 +- .../model/overrides/SchemaOverride.java | 37 ++- .../model/overrides/ShouldGenerate.java | 15 + .../client/codegen/openapi/OpenApiSchema.java | 20 +- .../client/codegen/utils/Markdown.java | 4 +- .../codegen/templates/EnumShape.mustache | 5 + .../templates/ObjectShape/Builder.mustache | 12 +- .../ObjectShape/Builder/SelfImpl.mustache | 2 +- .../ObjectShape/Deserialize.mustache | 4 + .../templates/Type/directSerializer.mustache | 11 +- 43 files changed, 1425 insertions(+), 645 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/AllField.java (83%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DataStreamTimestamp.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/FieldNamesField.java (81%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java (77%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceFieldMode.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/Alias.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java (70%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java (84%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/IndexState.java (81%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java diff --git a/UPGRADING.md b/UPGRADING.md index 4556772bea..c14f4e0821 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -51,4 +51,10 @@ After: - The `name` field, getter and builder method have been renamed to `repository`. ### CloneSnapshotRequest timeout removal -- The `timeout` field, getter and builder method have been removed from `CloneSnapshotRequest` as it is not supported by OpenSearch. \ No newline at end of file +- The `timeout` field, getter and builder method have been removed from `CloneSnapshotRequest` as it is not supported by OpenSearch. + +### DynamicMapping +- Removed the `Runtime` variant from the `DynamicMapping` enum as it is not supported by OpenSearch. + +### TypeMapping +- Removed the `runtime` field, getter and builder methods from `TypeMapping` as it is not supported by OpenSearch. \ No newline at end of file diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java index cbe9d63a80..2ddfefc198 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java @@ -45,6 +45,7 @@ import org.opensearch.client.opensearch.core.InfoRequest; import org.opensearch.client.opensearch.core.InfoResponse; import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesAsyncClient; +import org.opensearch.client.opensearch.indices.OpenSearchIndicesAsyncClient; import org.opensearch.client.opensearch.ml.OpenSearchMlAsyncClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotAsyncClient; import org.opensearch.client.opensearch.tasks.OpenSearchTasksAsyncClient; @@ -66,6 +67,10 @@ public OpenSearchDanglingIndicesAsyncClient danglingIndices() { return new OpenSearchDanglingIndicesAsyncClient(this.transport, this.transportOptions); } + public OpenSearchIndicesAsyncClient indices() { + return new OpenSearchIndicesAsyncClient(this.transport, this.transportOptions); + } + public OpenSearchMlAsyncClient ml() { return new OpenSearchMlAsyncClient(this.transport, this.transportOptions); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java index 36f4a912b6..eeedcc19fd 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java @@ -44,6 +44,7 @@ import org.opensearch.client.opensearch.core.InfoRequest; import org.opensearch.client.opensearch.core.InfoResponse; import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesClient; +import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient; import org.opensearch.client.opensearch.ml.OpenSearchMlClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotClient; import org.opensearch.client.opensearch.tasks.OpenSearchTasksClient; @@ -65,6 +66,10 @@ public OpenSearchDanglingIndicesClient danglingIndices() { return new OpenSearchDanglingIndicesClient(this.transport, this.transportOptions); } + public OpenSearchIndicesClient indices() { + return new OpenSearchIndicesClient(this.transport, this.transportOptions); + } + public OpenSearchMlClient ml() { return new OpenSearchMlClient(this.transport, this.transportOptions); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java similarity index 78% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java index 5b66a33bd2..cf64f63793 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java @@ -30,32 +30,33 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.ExpandWildcard + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum ExpandWildcard implements JsonEnum { /** - * Match any data stream or index, including hidden ones. + * Match any index, including hidden ones. */ All("all"), /** - * Match open, non-hidden indices. Also matches any non-hidden data stream. - */ - Open("open"), - - /** - * Match closed, non-hidden indices. Also matches any non-hidden data stream. - * Data streams cannot be closed. + * Match closed, non-hidden indices. */ Closed("closed"), /** - * Match hidden data streams and hidden indices. Must be combined with open, - * closed, or both. + * Match hidden indices. Must be combined with open, closed, or both. */ Hidden("hidden"), @@ -64,7 +65,10 @@ public enum ExpandWildcard implements JsonEnum { */ None("none"), - ; + /** + * Match open, non-hidden indices. + */ + Open("open"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/AllField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/AllField.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/AllField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/AllField.java index d9e675fdf9..223be35e58 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/AllField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/AllField.java @@ -30,10 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; 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; @@ -47,15 +53,20 @@ // typedef: _types.mapping.AllField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class AllField implements PlainJsonSerializable { + + @Nonnull private final String analyzer; private final boolean enabled; private final boolean omitNorms; + @Nonnull private final String searchAnalyzer; + @Nonnull private final String similarity; private final boolean store; @@ -71,7 +82,6 @@ public class AllField implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private AllField(Builder builder) { - this.analyzer = ApiTypeHelper.requireNonNull(builder.analyzer, this, "analyzer"); this.enabled = ApiTypeHelper.requireNonNull(builder.enabled, this, "enabled"); this.omitNorms = ApiTypeHelper.requireNonNull(builder.omitNorms, this, "omitNorms"); @@ -82,16 +92,16 @@ private AllField(Builder builder) { this.storeTermVectorPayloads = ApiTypeHelper.requireNonNull(builder.storeTermVectorPayloads, this, "storeTermVectorPayloads"); this.storeTermVectorPositions = ApiTypeHelper.requireNonNull(builder.storeTermVectorPositions, this, "storeTermVectorPositions"); this.storeTermVectors = ApiTypeHelper.requireNonNull(builder.storeTermVectors, this, "storeTermVectors"); - } - public static AllField of(Function> fn) { + public static AllField of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code analyzer} */ + @Nonnull public final String analyzer() { return this.analyzer; } @@ -113,6 +123,7 @@ public final boolean omitNorms() { /** * Required - API name: {@code search_analyzer} */ + @Nonnull public final String searchAnalyzer() { return this.searchAnalyzer; } @@ -120,6 +131,7 @@ public final String searchAnalyzer() { /** * Required - API name: {@code similarity} */ + @Nonnull public final String similarity() { return this.similarity; } @@ -162,6 +174,7 @@ public final boolean storeTermVectors() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -169,7 +182,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("analyzer"); generator.write(this.analyzer); @@ -199,7 +211,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("store_term_vectors"); generator.write(this.storeTermVectors); - } // --------------------------------------------------------------------------------------------- @@ -207,26 +218,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link AllField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private String analyzer; - private Boolean enabled; - private Boolean omitNorms; - private String searchAnalyzer; - private String similarity; - private Boolean store; - private Boolean storeTermVectorOffsets; - private Boolean storeTermVectorPayloads; - private Boolean storeTermVectorPositions; - private Boolean storeTermVectors; /** @@ -312,8 +313,7 @@ public final Builder storeTermVectors(boolean value) { /** * Builds a {@link AllField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public AllField build() { _checkSingleUse(); @@ -333,7 +333,6 @@ public AllField build() { ); protected static void setupAllFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::analyzer, JsonpDeserializer.stringDeserializer(), "analyzer"); op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); op.add(Builder::omitNorms, JsonpDeserializer.booleanDeserializer(), "omit_norms"); @@ -344,7 +343,38 @@ protected static void setupAllFieldDeserializer(ObjectDeserializer> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code enabled} + */ + public final boolean enabled() { + return this.enabled; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("enabled"); + generator.write(this.enabled); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DataStreamTimestamp}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Boolean enabled; + + /** + * Required - API name: {@code enabled} + */ + public final Builder enabled(boolean value) { + this.enabled = value; + return this; + } + + /** + * Builds a {@link DataStreamTimestamp}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public DataStreamTimestamp build() { + _checkSingleUse(); + + return new DataStreamTimestamp(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DataStreamTimestamp} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + DataStreamTimestamp::setupDataStreamTimestampDeserializer + ); + + protected static void setupDataStreamTimestampDeserializer(ObjectDeserializer op) { + op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.enabled); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + DataStreamTimestamp other = (DataStreamTimestamp) o; + return this.enabled == other.enabled; + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java index 0fe589b4c6..4daab1db6f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java @@ -30,22 +30,28 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.mapping.DynamicMapping + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum DynamicMapping implements JsonEnum { - Strict("strict"), - - Runtime("runtime"), + False("false"), - True("true"), + Strict("strict"), - False("false"), + StrictAllowTemplates("strict_allow_templates"), - ; + True("true"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java index 568ee8a3b3..1f9af30080 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java @@ -30,10 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; 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; @@ -47,7 +53,9 @@ // typedef: _types.mapping.DynamicTemplate @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class DynamicTemplate implements PlainJsonSerializable { + @Nullable private final Property mapping; @@ -72,7 +80,6 @@ public class DynamicTemplate implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private DynamicTemplate(Builder builder) { - this.mapping = builder.mapping; this.match = builder.match; this.matchMappingType = builder.matchMappingType; @@ -80,10 +87,9 @@ private DynamicTemplate(Builder builder) { this.pathMatch = builder.pathMatch; this.pathUnmatch = builder.pathUnmatch; this.unmatch = builder.unmatch; - } - public static DynamicTemplate of(Function> fn) { + public static DynamicTemplate of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -146,6 +152,7 @@ public final String unmatch() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -153,42 +160,40 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.mapping != null) { generator.writeKey("mapping"); this.mapping.serialize(generator, mapper); - } + if (this.match != null) { generator.writeKey("match"); generator.write(this.match); - } + if (this.matchMappingType != null) { generator.writeKey("match_mapping_type"); generator.write(this.matchMappingType); - } + if (this.matchPattern != null) { generator.writeKey("match_pattern"); this.matchPattern.serialize(generator, mapper); } + if (this.pathMatch != null) { generator.writeKey("path_match"); generator.write(this.pathMatch); - } + if (this.pathUnmatch != null) { generator.writeKey("path_unmatch"); generator.write(this.pathUnmatch); - } + if (this.unmatch != null) { generator.writeKey("unmatch"); generator.write(this.unmatch); - } - } // --------------------------------------------------------------------------------------------- @@ -196,26 +201,19 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link DynamicTemplate}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Property mapping; - @Nullable private String match; - @Nullable private String matchMappingType; - @Nullable private MatchType matchPattern; - @Nullable private String pathMatch; - @Nullable private String pathUnmatch; - @Nullable private String unmatch; @@ -231,7 +229,7 @@ public final Builder mapping(@Nullable Property value) { * API name: {@code mapping} */ public final Builder mapping(Function> fn) { - return this.mapping(fn.apply(new Property.Builder()).build()); + return mapping(fn.apply(new Property.Builder()).build()); } /** @@ -285,8 +283,7 @@ public final Builder unmatch(@Nullable String value) { /** * Builds a {@link DynamicTemplate}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public DynamicTemplate build() { _checkSingleUse(); @@ -306,7 +303,6 @@ public DynamicTemplate build() { ); protected static void setupDynamicTemplateDeserializer(ObjectDeserializer op) { - op.add(Builder::mapping, Property._DESERIALIZER, "mapping"); op.add(Builder::match, JsonpDeserializer.stringDeserializer(), "match"); op.add(Builder::matchMappingType, JsonpDeserializer.stringDeserializer(), "match_mapping_type"); @@ -314,7 +310,32 @@ protected static void setupDynamicTemplateDeserializer(ObjectDeserializer> fn) { + public static FieldNamesField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -72,6 +77,7 @@ public final boolean enabled() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -79,10 +85,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("enabled"); generator.write(this.enabled); - } // --------------------------------------------------------------------------------------------- @@ -90,7 +94,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link FieldNamesField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean enabled; @@ -105,8 +108,7 @@ public final Builder enabled(boolean value) { /** * Builds a {@link FieldNamesField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public FieldNamesField build() { _checkSingleUse(); @@ -126,9 +128,21 @@ public FieldNamesField build() { ); protected static void setupFieldNamesFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.enabled); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + FieldNamesField other = (FieldNamesField) o; + return this.enabled == other.enabled; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java index 47900c18c0..e5552869f7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; 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.JsonpMapper; @@ -47,18 +52,18 @@ // typedef: _types.mapping.IndexField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class IndexField implements PlainJsonSerializable { + private final boolean enabled; // --------------------------------------------------------------------------------------------- private IndexField(Builder builder) { - this.enabled = ApiTypeHelper.requireNonNull(builder.enabled, this, "enabled"); - } - public static IndexField of(Function> fn) { + public static IndexField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -72,6 +77,7 @@ public final boolean enabled() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -79,10 +85,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("enabled"); generator.write(this.enabled); - } // --------------------------------------------------------------------------------------------- @@ -90,7 +94,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IndexField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean enabled; @@ -105,8 +108,7 @@ public final Builder enabled(boolean value) { /** * Builds a {@link IndexField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IndexField build() { _checkSingleUse(); @@ -126,9 +128,21 @@ public IndexField build() { ); protected static void setupIndexFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.enabled); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndexField other = (IndexField) o; + return this.enabled == other.enabled; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java index b4a3f1330b..5a57d96751 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java @@ -30,18 +30,24 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.mapping.MatchType + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum MatchType implements JsonEnum { - Simple("simple"), - Regex("regex"), - ; + Simple("simple"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java index 3882835104..df5983d762 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; 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.JsonpMapper; @@ -47,18 +52,18 @@ // typedef: _types.mapping.RoutingField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class RoutingField implements PlainJsonSerializable { + private final boolean required; // --------------------------------------------------------------------------------------------- private RoutingField(Builder builder) { - this.required = ApiTypeHelper.requireNonNull(builder.required, this, "required"); - } - public static RoutingField of(Function> fn) { + public static RoutingField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -72,6 +77,7 @@ public final boolean required() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -79,10 +85,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("required"); generator.write(this.required); - } // --------------------------------------------------------------------------------------------- @@ -90,7 +94,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link RoutingField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean required; @@ -105,8 +108,7 @@ public final Builder required(boolean value) { /** * Builds a {@link RoutingField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public RoutingField build() { _checkSingleUse(); @@ -126,9 +128,21 @@ public RoutingField build() { ); protected static void setupRoutingFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::required, JsonpDeserializer.booleanDeserializer(), "required"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.required); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + RoutingField other = (RoutingField) o; + return this.required == other.required; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java index c0f633dbb1..a0cd45d19e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; 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.JsonpMapper; @@ -47,18 +52,18 @@ // typedef: _types.mapping.SizeField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class SizeField implements PlainJsonSerializable { + private final boolean enabled; // --------------------------------------------------------------------------------------------- private SizeField(Builder builder) { - this.enabled = ApiTypeHelper.requireNonNull(builder.enabled, this, "enabled"); - } - public static SizeField of(Function> fn) { + public static SizeField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -72,6 +77,7 @@ public final boolean enabled() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -79,10 +85,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("enabled"); generator.write(this.enabled); - } // --------------------------------------------------------------------------------------------- @@ -90,7 +94,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link SizeField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean enabled; @@ -105,8 +108,7 @@ public final Builder enabled(boolean value) { /** * Builds a {@link SizeField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public SizeField build() { _checkSingleUse(); @@ -126,9 +128,21 @@ public SizeField build() { ); protected static void setupSizeFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.enabled); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SizeField other = (SizeField) o; + return this.enabled == other.enabled; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java similarity index 77% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java index 6ff76552f3..ed9f03b83c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; import java.util.List; +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; @@ -50,7 +57,9 @@ // typedef: _types.mapping.SourceField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class SourceField implements PlainJsonSerializable { + @Nullable private final Boolean compress; @@ -60,23 +69,27 @@ public class SourceField implements PlainJsonSerializable { @Nullable private final Boolean enabled; + @Nonnull private final List excludes; + @Nonnull private final List includes; + @Nullable + private final SourceFieldMode mode; + // --------------------------------------------------------------------------------------------- private SourceField(Builder builder) { - this.compress = builder.compress; this.compressThreshold = builder.compressThreshold; this.enabled = builder.enabled; this.excludes = ApiTypeHelper.unmodifiable(builder.excludes); this.includes = ApiTypeHelper.unmodifiable(builder.includes); - + this.mode = builder.mode; } - public static SourceField of(Function> fn) { + public static SourceField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -107,6 +120,7 @@ public final Boolean enabled() { /** * API name: {@code excludes} */ + @Nonnull public final List excludes() { return this.excludes; } @@ -114,13 +128,23 @@ public final List excludes() { /** * API name: {@code includes} */ + @Nonnull public final List includes() { return this.includes; } + /** + * API name: {@code mode} + */ + @Nullable + public final SourceFieldMode mode() { + return this.mode; + } + /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -128,43 +152,43 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.compress != null) { generator.writeKey("compress"); generator.write(this.compress); - } + if (this.compressThreshold != null) { generator.writeKey("compress_threshold"); generator.write(this.compressThreshold); - } + if (this.enabled != null) { generator.writeKey("enabled"); generator.write(this.enabled); - } + if (ApiTypeHelper.isDefined(this.excludes)) { generator.writeKey("excludes"); generator.writeStartArray(); for (String item0 : this.excludes) { generator.write(item0); - } generator.writeEnd(); - } + if (ApiTypeHelper.isDefined(this.includes)) { generator.writeKey("includes"); generator.writeStartArray(); for (String item0 : this.includes) { generator.write(item0); - } generator.writeEnd(); - } + if (this.mode != null) { + generator.writeKey("mode"); + this.mode.serialize(generator, mapper); + } } // --------------------------------------------------------------------------------------------- @@ -172,22 +196,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link SourceField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder, PlainDeserializable { + @Override + public Builder self() { + return this; + } + @Nullable private Boolean compress; - @Nullable private String compressThreshold; - @Nullable private Boolean enabled; - @Nullable private List excludes; - @Nullable private List includes; + @Nullable + private SourceFieldMode mode; /** * API name: {@code compress} @@ -215,8 +241,10 @@ public final Builder enabled(@Nullable Boolean value) { /** * API name: {@code excludes} + * *

* Adds all elements of list to excludes. + *

*/ public final Builder excludes(List list) { this.excludes = _listAddAll(this.excludes, list); @@ -225,8 +253,10 @@ public final Builder excludes(List list) { /** * API name: {@code excludes} + * *

* Adds one or more values to excludes. + *

*/ public final Builder excludes(String value, String... values) { this.excludes = _listAdd(this.excludes, value, values); @@ -235,8 +265,10 @@ public final Builder excludes(String value, String... values) { /** * API name: {@code includes} + * *

* Adds all elements of list to includes. + *

*/ public final Builder includes(List list) { this.includes = _listAddAll(this.includes, list); @@ -245,30 +277,34 @@ public final Builder includes(List list) { /** * API name: {@code includes} + * *

* Adds one or more values to includes. + *

*/ public final Builder includes(String value, String... values) { this.includes = _listAdd(this.includes, value, values); return this; } + /** + * API name: {@code mode} + */ + public final Builder mode(@Nullable SourceFieldMode value) { + this.mode = value; + return this; + } + /** * Builds a {@link SourceField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public SourceField build() { _checkSingleUse(); return new SourceField(this); } - - @Override - public Builder self() { - return this; - } } // --------------------------------------------------------------------------------------------- @@ -282,13 +318,36 @@ public Builder self() { ); protected static void setupSourceFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::compress, JsonpDeserializer.booleanDeserializer(), "compress"); op.add(Builder::compressThreshold, JsonpDeserializer.stringDeserializer(), "compress_threshold"); op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); op.add(Builder::excludes, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "excludes"); op.add(Builder::includes, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "includes"); + op.add(Builder::mode, SourceFieldMode._DESERIALIZER, "mode"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.compress); + result = 31 * result + Objects.hashCode(this.compressThreshold); + result = 31 * result + Objects.hashCode(this.enabled); + result = 31 * result + Objects.hashCode(this.excludes); + result = 31 * result + Objects.hashCode(this.includes); + result = 31 * result + Objects.hashCode(this.mode); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SourceField other = (SourceField) o; + return Objects.equals(this.compress, other.compress) + && Objects.equals(this.compressThreshold, other.compressThreshold) + && Objects.equals(this.enabled, other.enabled) + && Objects.equals(this.excludes, other.excludes) + && Objects.equals(this.includes, other.includes) + && Objects.equals(this.mode, other.mode); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceFieldMode.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceFieldMode.java new file mode 100644 index 0000000000..f8ad5b9276 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceFieldMode.java @@ -0,0 +1,65 @@ +/* + * 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._types.mapping; + +import javax.annotation.Generated; +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +// typedef: _types.mapping.SourceFieldMode + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public enum SourceFieldMode implements JsonEnum { + Disabled("disabled"), + + Stored("stored"), + + Synthetic("synthetic"); + + private final String jsonValue; + + SourceFieldMode(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(SourceFieldMode.values()); +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java similarity index 79% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java index cbc74c0013..8df176779a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java @@ -30,12 +30,19 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; 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; @@ -52,31 +59,43 @@ // typedef: _types.mapping.TypeMapping @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class TypeMapping implements PlainJsonSerializable { + @Nullable private final AllField allField; + @Nullable + private final DataStreamTimestamp dataStreamTimestamp; + @Nullable private final Boolean dateDetection; @Nullable private final DynamicMapping dynamic; + @Nonnull private final List dynamicDateFormats; + @Nonnull private final List> dynamicTemplates; + @Nullable + private final Boolean enabled; + @Nullable private final FieldNamesField fieldNames; @Nullable private final IndexField indexField; + @Nonnull private final Map meta; @Nullable private final Boolean numericDetection; + @Nonnull private final Map properties; @Nullable @@ -88,20 +107,16 @@ public class TypeMapping implements PlainJsonSerializable { @Nullable private final SourceField source; - private final Map runtime; - - @Nullable - private final Boolean enabled; - // --------------------------------------------------------------------------------------------- private TypeMapping(Builder builder) { - this.allField = builder.allField; + this.dataStreamTimestamp = builder.dataStreamTimestamp; this.dateDetection = builder.dateDetection; this.dynamic = builder.dynamic; this.dynamicDateFormats = ApiTypeHelper.unmodifiable(builder.dynamicDateFormats); this.dynamicTemplates = ApiTypeHelper.unmodifiable(builder.dynamicTemplates); + this.enabled = builder.enabled; this.fieldNames = builder.fieldNames; this.indexField = builder.indexField; this.meta = ApiTypeHelper.unmodifiable(builder.meta); @@ -110,12 +125,9 @@ private TypeMapping(Builder builder) { this.routing = builder.routing; this.size = builder.size; this.source = builder.source; - this.runtime = ApiTypeHelper.unmodifiable(builder.runtime); - this.enabled = builder.enabled; - } - public static TypeMapping of(Function> fn) { + public static TypeMapping of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -127,6 +139,14 @@ public final AllField allField() { return this.allField; } + /** + * API name: {@code _data_stream_timestamp} + */ + @Nullable + public final DataStreamTimestamp dataStreamTimestamp() { + return this.dataStreamTimestamp; + } + /** * API name: {@code date_detection} */ @@ -146,6 +166,7 @@ public final DynamicMapping dynamic() { /** * API name: {@code dynamic_date_formats} */ + @Nonnull public final List dynamicDateFormats() { return this.dynamicDateFormats; } @@ -153,10 +174,19 @@ public final List dynamicDateFormats() { /** * API name: {@code dynamic_templates} */ + @Nonnull public final List> dynamicTemplates() { return this.dynamicTemplates; } + /** + * API name: {@code enabled} + */ + @Nullable + public final Boolean enabled() { + return this.enabled; + } + /** * API name: {@code _field_names} */ @@ -176,6 +206,7 @@ public final IndexField indexField() { /** * API name: {@code _meta} */ + @Nonnull public final Map meta() { return this.meta; } @@ -191,6 +222,7 @@ public final Boolean numericDetection() { /** * API name: {@code properties} */ + @Nonnull public final Map properties() { return this.properties; } @@ -219,24 +251,10 @@ public final SourceField source() { return this.source; } - /** - * API name: {@code runtime} - */ - public final Map runtime() { - return this.runtime; - } - - /** - * API name: {@code enabled} - */ - @Nullable - public final Boolean enabled() { - return this.enabled; - } - /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -244,31 +262,35 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.allField != null) { generator.writeKey("all_field"); this.allField.serialize(generator, mapper); + } + if (this.dataStreamTimestamp != null) { + generator.writeKey("_data_stream_timestamp"); + this.dataStreamTimestamp.serialize(generator, mapper); } + if (this.dateDetection != null) { generator.writeKey("date_detection"); generator.write(this.dateDetection); - } + if (this.dynamic != null) { generator.writeKey("dynamic"); this.dynamic.serialize(generator, mapper); } + if (ApiTypeHelper.isDefined(this.dynamicDateFormats)) { generator.writeKey("dynamic_date_formats"); generator.writeStartArray(); for (String item0 : this.dynamicDateFormats) { generator.write(item0); - } generator.writeEnd(); - } + if (ApiTypeHelper.isDefined(this.dynamicTemplates)) { generator.writeKey("dynamic_templates"); generator.writeStartArray(); @@ -278,84 +300,67 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); item1.getValue().serialize(generator, mapper); - } } generator.writeEnd(); - } generator.writeEnd(); + } + if (this.enabled != null) { + generator.writeKey("enabled"); + generator.write(this.enabled); } + if (this.fieldNames != null) { generator.writeKey("_field_names"); this.fieldNames.serialize(generator, mapper); - } + if (this.indexField != null) { generator.writeKey("index_field"); this.indexField.serialize(generator, 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.numericDetection != null) { generator.writeKey("numeric_detection"); generator.write(this.numericDetection); - } + if (ApiTypeHelper.isDefined(this.properties)) { generator.writeKey("properties"); generator.writeStartObject(); for (Map.Entry item0 : this.properties.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.routing != null) { generator.writeKey("_routing"); this.routing.serialize(generator, mapper); - } + if (this.size != null) { generator.writeKey("_size"); this.size.serialize(generator, mapper); - } + if (this.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); - } - if (ApiTypeHelper.isDefined(this.runtime)) { - generator.writeKey("runtime"); - generator.writeStartObject(); - for (Map.Entry item0 : this.runtime.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - - } - if (this.enabled != null) { - generator.writeKey("enabled"); - generator.write(this.enabled); - - } - } // --------------------------------------------------------------------------------------------- @@ -363,53 +368,43 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link TypeMapping}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder, PlainDeserializable { + @Override + public Builder self() { + return this; + } + @Nullable private AllField allField; - + @Nullable + private DataStreamTimestamp dataStreamTimestamp; @Nullable private Boolean dateDetection; - @Nullable private DynamicMapping dynamic; - @Nullable private List dynamicDateFormats; - @Nullable private List> dynamicTemplates; - + @Nullable + private Boolean enabled; @Nullable private FieldNamesField fieldNames; - @Nullable private IndexField indexField; - @Nullable private Map meta; - @Nullable private Boolean numericDetection; - @Nullable private Map properties; - @Nullable private RoutingField routing; - @Nullable private SizeField size; - @Nullable private SourceField source; - @Nullable - private Map runtime; - - @Nullable - private Boolean enabled; - /** * API name: {@code all_field} */ @@ -422,7 +417,22 @@ public final Builder allField(@Nullable AllField value) { * API name: {@code all_field} */ public final Builder allField(Function> fn) { - return this.allField(fn.apply(new AllField.Builder()).build()); + return allField(fn.apply(new AllField.Builder()).build()); + } + + /** + * API name: {@code _data_stream_timestamp} + */ + public final Builder dataStreamTimestamp(@Nullable DataStreamTimestamp value) { + this.dataStreamTimestamp = value; + return this; + } + + /** + * API name: {@code _data_stream_timestamp} + */ + public final Builder dataStreamTimestamp(Function> fn) { + return dataStreamTimestamp(fn.apply(new DataStreamTimestamp.Builder()).build()); } /** @@ -443,8 +453,10 @@ public final Builder dynamic(@Nullable DynamicMapping value) { /** * API name: {@code dynamic_date_formats} + * *

* Adds all elements of list to dynamicDateFormats. + *

*/ public final Builder dynamicDateFormats(List list) { this.dynamicDateFormats = _listAddAll(this.dynamicDateFormats, list); @@ -453,8 +465,10 @@ public final Builder dynamicDateFormats(List list) { /** * API name: {@code dynamic_date_formats} + * *

* Adds one or more values to dynamicDateFormats. + *

*/ public final Builder dynamicDateFormats(String value, String... values) { this.dynamicDateFormats = _listAdd(this.dynamicDateFormats, value, values); @@ -463,8 +477,10 @@ public final Builder dynamicDateFormats(String value, String... values) { /** * API name: {@code dynamic_templates} + * *

* Adds all elements of list to dynamicTemplates. + *

*/ public final Builder dynamicTemplates(List> list) { this.dynamicTemplates = _listAddAll(this.dynamicTemplates, list); @@ -473,14 +489,24 @@ public final Builder dynamicTemplates(List> list) { /** * API name: {@code dynamic_templates} + * *

* Adds one or more values to dynamicTemplates. + *

*/ public final Builder dynamicTemplates(Map value, Map... values) { this.dynamicTemplates = _listAdd(this.dynamicTemplates, value, values); return this; } + /** + * API name: {@code enabled} + */ + public final Builder enabled(@Nullable Boolean value) { + this.enabled = value; + return this; + } + /** * API name: {@code _field_names} */ @@ -493,7 +519,7 @@ public final Builder fieldNames(@Nullable FieldNamesField value) { * API name: {@code _field_names} */ public final Builder fieldNames(Function> fn) { - return this.fieldNames(fn.apply(new FieldNamesField.Builder()).build()); + return fieldNames(fn.apply(new FieldNamesField.Builder()).build()); } /** @@ -508,13 +534,15 @@ public final Builder indexField(@Nullable IndexField value) { * API name: {@code index_field} */ public final Builder indexField(Function> fn) { - return this.indexField(fn.apply(new IndexField.Builder()).build()); + return indexField(fn.apply(new IndexField.Builder()).build()); } /** * 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); @@ -523,8 +551,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); @@ -541,8 +571,10 @@ public final Builder numericDetection(@Nullable Boolean value) { /** * API name: {@code properties} + * *

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

*/ public final Builder properties(Map map) { this.properties = _mapPutAll(this.properties, map); @@ -551,8 +583,10 @@ public final Builder properties(Map map) { /** * API name: {@code properties} + * *

* Adds an entry to properties. + *

*/ public final Builder properties(String key, Property value) { this.properties = _mapPut(this.properties, key, value); @@ -561,8 +595,10 @@ public final Builder properties(String key, Property value) { /** * API name: {@code properties} + * *

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

*/ public final Builder properties(String key, Function> fn) { return properties(key, fn.apply(new Property.Builder()).build()); @@ -580,7 +616,7 @@ public final Builder routing(@Nullable RoutingField value) { * API name: {@code _routing} */ public final Builder routing(Function> fn) { - return this.routing(fn.apply(new RoutingField.Builder()).build()); + return routing(fn.apply(new RoutingField.Builder()).build()); } /** @@ -595,7 +631,7 @@ public final Builder size(@Nullable SizeField value) { * API name: {@code _size} */ public final Builder size(Function> fn) { - return this.size(fn.apply(new SizeField.Builder()).build()); + return size(fn.apply(new SizeField.Builder()).build()); } /** @@ -610,62 +646,19 @@ public final Builder source(@Nullable SourceField value) { * API name: {@code _source} */ public final Builder source(Function> fn) { - return this.source(fn.apply(new SourceField.Builder()).build()); - } - - /** - * API name: {@code runtime} - *

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

- * Adds an entry to runtime. - */ - public final Builder runtime(String key, RuntimeField value) { - this.runtime = _mapPut(this.runtime, key, value); - return this; - } - - /** - * API name: {@code runtime} - *

- * Adds an entry to runtime using a builder lambda. - */ - public final Builder runtime(String key, Function> fn) { - return runtime(key, fn.apply(new RuntimeField.Builder()).build()); - } - - /** - * API name: {@code enabled} - */ - public final Builder enabled(@Nullable Boolean value) { - this.enabled = value; - return this; + return source(fn.apply(new SourceField.Builder()).build()); } /** * Builds a {@link TypeMapping}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public TypeMapping build() { _checkSingleUse(); return new TypeMapping(this); } - - @Override - public Builder self() { - return this; - } } // --------------------------------------------------------------------------------------------- @@ -679,8 +672,8 @@ public Builder self() { ); protected static void setupTypeMappingDeserializer(ObjectDeserializer op) { - op.add(Builder::allField, AllField._DESERIALIZER, "all_field"); + op.add(Builder::dataStreamTimestamp, DataStreamTimestamp._DESERIALIZER, "_data_stream_timestamp"); op.add(Builder::dateDetection, JsonpDeserializer.booleanDeserializer(), "date_detection"); op.add(Builder::dynamic, DynamicMapping._DESERIALIZER, "dynamic"); op.add( @@ -693,6 +686,7 @@ protected static void setupTypeMappingDeserializer(ObjectDeserializer> fn) { + public static Alias of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -101,7 +107,10 @@ public final String indexRouting() { } /** + * If true, the alias is hidden. All indices for the alias must have the same is_hidden value. + *

* API name: {@code is_hidden} + *

*/ @Nullable public final Boolean isHidden() { @@ -109,7 +118,10 @@ public final Boolean isHidden() { } /** + * If true, the index is the write index for the alias. + *

* API name: {@code is_write_index} + *

*/ @Nullable public final Boolean isWriteIndex() { @@ -135,6 +147,7 @@ public final String searchRouting() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -142,38 +155,35 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.filter != null) { generator.writeKey("filter"); this.filter.serialize(generator, mapper); - } + if (this.indexRouting != null) { generator.writeKey("index_routing"); generator.write(this.indexRouting); - } + if (this.isHidden != null) { generator.writeKey("is_hidden"); generator.write(this.isHidden); - } + if (this.isWriteIndex != null) { generator.writeKey("is_write_index"); generator.write(this.isWriteIndex); - } + if (this.routing != null) { generator.writeKey("routing"); generator.write(this.routing); - } + if (this.searchRouting != null) { generator.writeKey("search_routing"); generator.write(this.searchRouting); - } - } // --------------------------------------------------------------------------------------------- @@ -181,23 +191,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link Alias}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Query filter; - @Nullable private String indexRouting; - @Nullable private Boolean isHidden; - @Nullable private Boolean isWriteIndex; - @Nullable private String routing; - @Nullable private String searchRouting; @@ -213,7 +217,7 @@ public final Builder filter(@Nullable Query value) { * API name: {@code filter} */ public final Builder filter(Function> fn) { - return this.filter(fn.apply(new Query.Builder()).build()); + return filter(fn.apply(new Query.Builder()).build()); } /** @@ -225,7 +229,10 @@ public final Builder indexRouting(@Nullable String value) { } /** + * If true, the alias is hidden. All indices for the alias must have the same is_hidden value. + *

* API name: {@code is_hidden} + *

*/ public final Builder isHidden(@Nullable Boolean value) { this.isHidden = value; @@ -233,7 +240,10 @@ public final Builder isHidden(@Nullable Boolean value) { } /** + * If true, the index is the write index for the alias. + *

* API name: {@code is_write_index} + *

*/ public final Builder isWriteIndex(@Nullable Boolean value) { this.isWriteIndex = value; @@ -259,8 +269,7 @@ public final Builder searchRouting(@Nullable String value) { /** * Builds a {@link Alias}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public Alias build() { _checkSingleUse(); @@ -280,14 +289,36 @@ public Alias build() { ); protected static void setupAliasDeserializer(ObjectDeserializer op) { - op.add(Builder::filter, Query._DESERIALIZER, "filter"); op.add(Builder::indexRouting, JsonpDeserializer.stringDeserializer(), "index_routing"); op.add(Builder::isHidden, JsonpDeserializer.booleanDeserializer(), "is_hidden"); op.add(Builder::isWriteIndex, JsonpDeserializer.booleanDeserializer(), "is_write_index"); op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "routing"); op.add(Builder::searchRouting, JsonpDeserializer.stringDeserializer(), "search_routing"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.filter); + result = 31 * result + Objects.hashCode(this.indexRouting); + result = 31 * result + Objects.hashCode(this.isHidden); + result = 31 * result + Objects.hashCode(this.isWriteIndex); + result = 31 * result + Objects.hashCode(this.routing); + result = 31 * result + Objects.hashCode(this.searchRouting); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + Alias other = (Alias) o; + return Objects.equals(this.filter, other.filter) + && Objects.equals(this.indexRouting, other.indexRouting) + && Objects.equals(this.isHidden, other.isHidden) + && Objects.equals(this.isWriteIndex, other.isWriteIndex) + && Objects.equals(this.routing, other.routing) + && Objects.equals(this.searchRouting, other.searchRouting); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java index 4049613f69..a30b95e2f5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexRequest.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 java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; +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.ExpandWildcard; @@ -52,13 +59,17 @@ /** * Returns information about one or more indices. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetIndexRequest extends RequestBase { + @Nullable private final Boolean allowNoIndices; + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final List expandWildcards; @Nullable @@ -70,6 +81,7 @@ public class GetIndexRequest extends RequestBase { @Nullable private final Boolean includeDefaults; + @Nonnull private final List index; @Nullable @@ -79,14 +91,11 @@ public class GetIndexRequest extends RequestBase { @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - // --------------------------------------------------------------------------------------------- private GetIndexRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.flatSettings = builder.flatSettings; this.ignoreUnavailable = builder.ignoreUnavailable; @@ -94,19 +103,19 @@ private GetIndexRequest(Builder builder) { this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index"); this.local = builder.local; this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - } - public static GetIndexRequest of(Function> fn) { + public static GetIndexRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Ignore if a wildcard expression resolves to no concrete indices (default: - * false) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. + * This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if + * an index starts with foo but no index starts with bar. *

* API name: {@code allow_no_indices} + *

*/ @Nullable public final Boolean allowNoIndices() { @@ -114,12 +123,24 @@ public final Boolean allowNoIndices() { } /** - * Type of index that wildcard expressions can match. If the request can target - * data streams, this argument determines whether wildcard expressions match - * hidden data streams. Supports comma-separated values, such as open,hidden. + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether wildcard + * expressions match hidden data streams. Supports comma-separated values, such as open,hidden. *

* API name: {@code expand_wildcards} + *

*/ + @Nonnull public final List expandWildcards() { return this.expandWildcards; } @@ -128,6 +149,7 @@ public final List expandWildcards() { * If true, returns settings in flat format. *

* API name: {@code flat_settings} + *

*/ @Nullable public final Boolean flatSettings() { @@ -138,6 +160,7 @@ public final Boolean flatSettings() { * If false, requests that target a missing index return an error. *

* API name: {@code ignore_unavailable} + *

*/ @Nullable public final Boolean ignoreUnavailable() { @@ -148,6 +171,7 @@ public final Boolean ignoreUnavailable() { * If true, return all default settings in the response. *

* API name: {@code include_defaults} + *

*/ @Nullable public final Boolean includeDefaults() { @@ -155,20 +179,23 @@ public final Boolean includeDefaults() { } /** - * Required - Comma-separated list of data streams, indices, and index aliases - * used to limit the request. Wildcard expressions (*) are supported. + * Required - Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are + * supported. *

* API name: {@code index} + *

*/ + @Nonnull public final List index() { return this.index; } /** - * 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() { @@ -176,10 +203,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 @@ -187,56 +215,37 @@ public final Time masterTimeout() { return this.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; - } - // --------------------------------------------------------------------------------------------- /** * Builder for {@link GetIndexRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Boolean allowNoIndices; - + @Nullable + private Time clusterManagerTimeout; @Nullable private List expandWildcards; - @Nullable private Boolean flatSettings; - @Nullable private Boolean ignoreUnavailable; - @Nullable private Boolean includeDefaults; - private List index; - @Nullable private Boolean local; - - @Deprecated @Nullable private Time masterTimeout; - @Nullable - private Time clusterManagerTimeout; - /** - * Ignore if a wildcard expression resolves to no concrete indices (default: - * false) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed + * indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns + * an error if an index starts with foo but no index starts with bar. *

* API name: {@code allow_no_indices} + *

*/ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; @@ -244,13 +253,36 @@ public final Builder allowNoIndices(@Nullable Boolean value) { } /** - * Type of index that wildcard expressions can match. If the request can target - * data streams, this argument determines whether wildcard expressions match - * hidden data streams. Supports comma-separated values, such as open,hidden. + * 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()); + } + + /** + * Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether + * wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds all elements of list to expandWildcards. + *

*/ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); @@ -258,13 +290,15 @@ public final Builder expandWildcards(List list) { } /** - * Type of index that wildcard expressions can match. If the request can target - * data streams, this argument determines whether wildcard expressions match - * hidden data streams. Supports comma-separated values, such as open,hidden. + * Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether + * wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds one or more values to expandWildcards. + *

*/ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); @@ -275,6 +309,7 @@ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... val * If true, returns settings in flat format. *

* API name: {@code flat_settings} + *

*/ public final Builder flatSettings(@Nullable Boolean value) { this.flatSettings = value; @@ -285,6 +320,7 @@ public final Builder flatSettings(@Nullable Boolean value) { * If false, requests that target a missing index return an error. *

* API name: {@code ignore_unavailable} + *

*/ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; @@ -295,6 +331,7 @@ public final Builder ignoreUnavailable(@Nullable Boolean value) { * If true, return all default settings in the response. *

* API name: {@code include_defaults} + *

*/ public final Builder includeDefaults(@Nullable Boolean value) { this.includeDefaults = value; @@ -302,12 +339,15 @@ public final Builder includeDefaults(@Nullable Boolean value) { } /** - * Required - Comma-separated list of data streams, indices, and index aliases - * used to limit the request. Wildcard expressions (*) are supported. + * Required - Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) + * are supported. *

* API name: {@code index} + *

+ * *

* Adds all elements of list to index. + *

*/ public final Builder index(List list) { this.index = _listAddAll(this.index, list); @@ -315,12 +355,15 @@ public final Builder index(List list) { } /** - * Required - Comma-separated list of data streams, indices, and index aliases - * used to limit the request. Wildcard expressions (*) are supported. + * Required - Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) + * are supported. *

* API name: {@code index} + *

+ * *

* Adds one or more values to index. + *

*/ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); @@ -328,10 +371,11 @@ public final Builder index(String value, String... values) { } /** - * 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; @@ -339,10 +383,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) { @@ -351,42 +396,21 @@ 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; - } - - /** - * 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()); + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** * Builds a {@link GetIndexRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public GetIndexRequest build() { _checkSingleUse(); @@ -401,63 +425,77 @@ public GetIndexRequest build() { * Endpoint "{@code indices.get}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // Request path request -> { - final int _index = 1 << 0; - - int propsSet = 0; - - propsSet |= _index; - - if (propsSet == (_index)) { - StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } 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 (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } + if (request.flatSettings != null) { + params.put("flat_settings", String.valueOf(request.flatSettings)); + } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } - if (request.allowNoIndices != null) { - params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); - } if (request.includeDefaults != null) { params.put("include_defaults", String.valueOf(request.includeDefaults)); } 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, GetIndexResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowNoIndices); + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.expandWildcards); + result = 31 * result + Objects.hashCode(this.flatSettings); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.includeDefaults); + result = 31 * result + this.index.hashCode(); + result = 31 * result + Objects.hashCode(this.local); + result = 31 * result + Objects.hashCode(this.masterTimeout); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + GetIndexRequest other = (GetIndexRequest) o; + return Objects.equals(this.allowNoIndices, other.allowNoIndices) + && Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.expandWildcards, other.expandWildcards) + && Objects.equals(this.flatSettings, other.flatSettings) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.includeDefaults, other.includeDefaults) + && this.index.equals(other.index) + && Objects.equals(this.local, other.local) + && Objects.equals(this.masterTimeout, other.masterTimeout); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java similarity index 84% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java index 5cd71afc55..cc79d9cbda 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexResponse.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,15 @@ // typedef: indices.get.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetIndexResponse extends DictionaryResponse { // --------------------------------------------------------------------------------------------- private GetIndexResponse(Builder builder) { super(builder); - } - public static GetIndexResponse of(Function> fn) { + public static GetIndexResponse of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -60,7 +65,6 @@ public static GetIndexResponse of(Function implements ObjectBuilder { @@ -72,8 +76,7 @@ protected Builder self() { /** * Builds a {@link GetIndexResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public GetIndexResponse build() { _checkSingleUse(); @@ -95,8 +98,6 @@ public GetIndexResponse build() { ); protected static void setupGetIndexResponseDeserializer(ObjectDeserializer op) { - DictionaryResponse.setupDictionaryResponseDeserializer(op, JsonpDeserializer.stringDeserializer(), IndexState._DESERIALIZER); - + setupDictionaryResponseDeserializer(op, JsonpDeserializer.stringDeserializer(), IndexState._DESERIALIZER); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexState.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexState.java similarity index 81% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexState.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexState.java index d24e42858c..da4c86fbf1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexState.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexState.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 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; @@ -47,85 +54,85 @@ import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: indices._types.IndexState +// typedef: indices.IndexState @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class IndexState implements PlainJsonSerializable { + + @Nonnull private final Map aliases; @Nullable - private final TypeMapping mappings; + private final String dataStream; @Nullable - private final IndexSettings settings; + private final IndexSettings defaults; @Nullable - private final IndexSettings defaults; + private final TypeMapping mappings; @Nullable - private final String dataStream; + private final IndexSettings settings; // --------------------------------------------------------------------------------------------- private IndexState(Builder builder) { - this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); + this.dataStream = builder.dataStream; + this.defaults = builder.defaults; this.mappings = builder.mappings; this.settings = builder.settings; - this.defaults = builder.defaults; - this.dataStream = builder.dataStream; - } - public static IndexState of(Function> fn) { + public static IndexState of(Function> fn) { return fn.apply(new Builder()).build(); } /** * API name: {@code aliases} */ + @Nonnull public final Map aliases() { return this.aliases; } /** - * API name: {@code mappings} + * API name: {@code data_stream} */ @Nullable - public final TypeMapping mappings() { - return this.mappings; + public final String dataStream() { + return this.dataStream; } /** - * API name: {@code settings} + * API name: {@code defaults} */ @Nullable - public final IndexSettings settings() { - return this.settings; + public final IndexSettings defaults() { + return this.defaults; } /** - * Default settings, included when the request's include_default is - * true. - *

- * API name: {@code defaults} + * API name: {@code mappings} */ @Nullable - public final IndexSettings defaults() { - return this.defaults; + public final TypeMapping mappings() { + return this.mappings; } /** - * API name: {@code data_stream} + * API name: {@code settings} */ @Nullable - public final String dataStream() { - return this.dataStream; + 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); @@ -133,39 +140,35 @@ 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.dataStream != null) { + generator.writeKey("data_stream"); + generator.write(this.dataStream); } - if (this.settings != null) { - generator.writeKey("settings"); - this.settings.serialize(generator, mapper); - } if (this.defaults != null) { generator.writeKey("defaults"); this.defaults.serialize(generator, mapper); - } - if (this.dataStream != null) { - generator.writeKey("data_stream"); - generator.write(this.dataStream); + if (this.mappings != null) { + generator.writeKey("mappings"); + this.mappings.serialize(generator, mapper); } + if (this.settings != null) { + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); + } } // --------------------------------------------------------------------------------------------- @@ -173,27 +176,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IndexState}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Map aliases; - @Nullable - private TypeMapping mappings; - - @Nullable - private IndexSettings settings; - + private String dataStream; @Nullable private IndexSettings defaults; - @Nullable - private String dataStream; + private TypeMapping mappings; + @Nullable + private IndexSettings settings; /** * 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); @@ -202,8 +202,10 @@ public final Builder aliases(Map map) { /** * API name: {@code aliases} + * *

* Adds an entry to aliases. + *

*/ public final Builder aliases(String key, Alias value) { this.aliases = _mapPut(this.aliases, key, value); @@ -212,77 +214,72 @@ public final Builder aliases(String key, Alias value) { /** * 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()); } /** - * API name: {@code mappings} + * API name: {@code data_stream} */ - public final Builder mappings(@Nullable TypeMapping value) { - this.mappings = value; + public final Builder dataStream(@Nullable String value) { + this.dataStream = value; return this; } /** - * API name: {@code mappings} + * API name: {@code defaults} */ - public final Builder mappings(Function> fn) { - return this.mappings(fn.apply(new TypeMapping.Builder()).build()); + public final Builder defaults(@Nullable IndexSettings value) { + this.defaults = value; + return this; } /** - * API name: {@code settings} + * API name: {@code defaults} */ - public final Builder settings(@Nullable IndexSettings value) { - this.settings = value; - return this; + public final Builder defaults(Function> fn) { + return defaults(fn.apply(new IndexSettings.Builder()).build()); } /** - * API name: {@code settings} + * API name: {@code mappings} */ - public final Builder settings(Function> fn) { - return this.settings(fn.apply(new IndexSettings.Builder()).build()); + public final Builder mappings(@Nullable TypeMapping value) { + this.mappings = value; + return this; } /** - * Default settings, included when the request's include_default is - * true. - *

- * API name: {@code defaults} + * API name: {@code mappings} */ - public final Builder defaults(@Nullable IndexSettings value) { - this.defaults = value; - return this; + public final Builder mappings(Function> fn) { + return mappings(fn.apply(new TypeMapping.Builder()).build()); } /** - * Default settings, included when the request's include_default is - * true. - *

- * API name: {@code defaults} + * API name: {@code settings} */ - public final Builder defaults(Function> fn) { - return this.defaults(fn.apply(new IndexSettings.Builder()).build()); + public final Builder settings(@Nullable IndexSettings value) { + this.settings = value; + return this; } /** - * API name: {@code data_stream} + * API name: {@code settings} */ - public final Builder dataStream(@Nullable String value) { - this.dataStream = value; - return this; + public final Builder settings(Function> fn) { + return settings(fn.apply(new IndexSettings.Builder()).build()); } /** * Builds a {@link IndexState}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IndexState build() { _checkSingleUse(); @@ -302,13 +299,33 @@ public IndexState build() { ); protected static void setupIndexStateDeserializer(ObjectDeserializer op) { - op.add(Builder::aliases, JsonpDeserializer.stringMapDeserializer(Alias._DESERIALIZER), "aliases"); + op.add(Builder::dataStream, JsonpDeserializer.stringDeserializer(), "data_stream"); + op.add(Builder::defaults, IndexSettings._DESERIALIZER, "defaults"); op.add(Builder::mappings, TypeMapping._DESERIALIZER, "mappings"); op.add(Builder::settings, IndexSettings._DESERIALIZER, "settings"); - op.add(Builder::defaults, IndexSettings._DESERIALIZER, "defaults"); - op.add(Builder::dataStream, JsonpDeserializer.stringDeserializer(), "data_stream"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.aliases); + result = 31 * result + Objects.hashCode(this.dataStream); + result = 31 * result + Objects.hashCode(this.defaults); + 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; + IndexState other = (IndexState) o; + return Objects.equals(this.aliases, other.aliases) + && Objects.equals(this.dataStream, other.dataStream) + && Objects.equals(this.defaults, other.defaults) + && 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 new file mode 100644 index 0000000000..c2c8de6ef6 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java @@ -0,0 +1,79 @@ +/* + * 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.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.util.ObjectBuilder; + +/** + * Client for the indices namespace. + */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public abstract class OpenSearchIndicesAsyncClientBase> extends ApiClient< + OpenSearchTransport, + Self> { + public OpenSearchIndicesAsyncClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + // ----- Endpoint: indices.get + + /** + * Returns information about one or more indices. + */ + public CompletableFuture get(GetIndexRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, GetIndexRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about one or more indices. + * + * @param fn a function that initializes a builder to create the {@link GetIndexRequest} + */ + public final CompletableFuture get(Function> fn) + throws IOException, OpenSearchException { + return get(fn.apply(new GetIndexRequest.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 new file mode 100644 index 0000000000..b0d7e141b6 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java @@ -0,0 +1,78 @@ +/* + * 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.io.IOException; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.util.ObjectBuilder; + +/** + * Client for the indices namespace. + */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public abstract class OpenSearchIndicesClientBase> extends ApiClient< + OpenSearchTransport, + Self> { + public OpenSearchIndicesClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + // ----- Endpoint: indices.get + + /** + * Returns information about one or more indices. + */ + public GetIndexResponse get(GetIndexRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, GetIndexRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about one or more indices. + * + * @param fn a function that initializes a builder to create the {@link GetIndexRequest} + */ + public final GetIndexResponse get(Function> fn) throws IOException, + OpenSearchException { + return get(fn.apply(new GetIndexRequest.Builder()).build()); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java index a0aca846f8..78ffa50708 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java @@ -120,7 +120,6 @@ import org.opensearch.client.opensearch.core.pit.ListAllPitRequest; import org.opensearch.client.opensearch.core.pit.ListAllPitResponse; import org.opensearch.client.opensearch.features.OpenSearchFeaturesAsyncClient; -import org.opensearch.client.opensearch.indices.OpenSearchIndicesAsyncClient; import org.opensearch.client.opensearch.ingest.OpenSearchIngestAsyncClient; import org.opensearch.client.opensearch.nodes.OpenSearchNodesAsyncClient; import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownAsyncClient; @@ -163,10 +162,6 @@ public OpenSearchFeaturesAsyncClient features() { return new OpenSearchFeaturesAsyncClient(this.transport, this.transportOptions); } - public OpenSearchIndicesAsyncClient indices() { - return new OpenSearchIndicesAsyncClient(this.transport, this.transportOptions); - } - public OpenSearchIngestAsyncClient ingest() { return new OpenSearchIngestAsyncClient(this.transport, this.transportOptions); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java index 4327951b80..b783518ab7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java @@ -120,7 +120,6 @@ import org.opensearch.client.opensearch.core.pit.ListAllPitResponse; import org.opensearch.client.opensearch.features.OpenSearchFeaturesClient; import org.opensearch.client.opensearch.generic.OpenSearchGenericClient; -import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient; import org.opensearch.client.opensearch.ingest.OpenSearchIngestClient; import org.opensearch.client.opensearch.nodes.OpenSearchNodesClient; import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownClient; @@ -166,10 +165,6 @@ public OpenSearchFeaturesClient features() { return new OpenSearchFeaturesClient(this.transport, this.transportOptions); } - public OpenSearchIndicesClient indices() { - return new OpenSearchIndicesClient(this.transport, this.transportOptions); - } - public OpenSearchIngestClient ingest() { return new OpenSearchIngestClient(this.transport, this.transportOptions); } 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 d2a4087e40..0755cbd356 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 @@ -36,7 +36,6 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Function; import javax.annotation.Nullable; -import org.opensearch.client.ApiClient; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.transport.JsonEndpoint; @@ -48,7 +47,7 @@ /** * Client for the indices namespace. */ -public class OpenSearchIndicesAsyncClient extends ApiClient { +public class OpenSearchIndicesAsyncClient extends OpenSearchIndicesAsyncClientBase { public OpenSearchIndicesAsyncClient(OpenSearchTransport transport) { super(transport, null); @@ -726,38 +725,6 @@ public CompletableFuture forcemerge() throws IOException, Op ); } - // ----- Endpoint: indices.get - - /** - * Returns information about one or more indices. - * - * - */ - - public CompletableFuture get(GetIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetIndexRequest, - GetIndexResponse, - ErrorResponse>) GetIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about one or more indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetIndexRequest} - * - */ - - public final CompletableFuture get(Function> fn) - throws IOException, OpenSearchException { - return get(fn.apply(new GetIndexRequest.Builder()).build()); - } - // ----- Endpoint: indices.get_data_stream /** 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 a3bdd52d4e..43e61e0c08 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 @@ -35,7 +35,6 @@ import java.io.IOException; import java.util.function.Function; import javax.annotation.Nullable; -import org.opensearch.client.ApiClient; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.transport.JsonEndpoint; @@ -47,7 +46,7 @@ /** * Client for the indices namespace. */ -public class OpenSearchIndicesClient extends ApiClient { +public class OpenSearchIndicesClient extends OpenSearchIndicesClientBase { public OpenSearchIndicesClient(OpenSearchTransport transport) { super(transport, null); @@ -702,38 +701,6 @@ public ForcemergeResponse forcemerge() throws IOException, OpenSearchException { return this.transport.performRequest(new ForcemergeRequest.Builder().build(), ForcemergeRequest._ENDPOINT, this.transportOptions); } - // ----- Endpoint: indices.get - - /** - * Returns information about one or more indices. - * - * - */ - - public GetIndexResponse get(GetIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetIndexRequest, - GetIndexResponse, - ErrorResponse>) GetIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about one or more indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetIndexRequest} - * - */ - - public final GetIndexResponse get(Function> fn) throws IOException, - OpenSearchException { - return get(fn.apply(new GetIndexRequest.Builder()).build()); - } - // ----- Endpoint: indices.get_data_stream /** diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/model/EnumTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/model/EnumTest.java index adbe18465c..e62d4cdf06 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/model/EnumTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/model/EnumTest.java @@ -61,8 +61,8 @@ public void testEnumWithBooleanSupport() { DynamicMapping booleanAsString = fromJson("\"true\"", DynamicMapping.class); assertEquals(booleanAsString, DynamicMapping.True); - DynamicMapping nonBooleanEnumValue = fromJson("\"runtime\"", DynamicMapping.class); - assertEquals(nonBooleanEnumValue, DynamicMapping.Runtime); + DynamicMapping nonBooleanEnumValue = fromJson("\"strict\"", DynamicMapping.class); + assertEquals(nonBooleanEnumValue, DynamicMapping.Strict); DynamicMapping booleanPrimitive = fromJson("false", DynamicMapping.class); assertEquals(booleanPrimitive, DynamicMapping.False); 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 70d12db927..8aaa9eb50d 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,6 +43,7 @@ public class CodeGenerator { private static final OperationGroupMatcher OPERATION_MATCHER = or( and(namespace(""), named("info")), namespace("dangling_indices"), + and(namespace("indices"), named("get")), 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/EnumShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java index 90a2fae57c..1150a1813f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java @@ -13,7 +13,9 @@ import java.util.List; import java.util.Set; import java.util.TreeMap; +import javax.annotation.Nullable; import org.opensearch.client.codegen.utils.JavaClassKind; +import org.opensearch.client.codegen.utils.Markdown; import org.opensearch.client.codegen.utils.Strings; public class EnumShape extends Shape { @@ -38,14 +40,17 @@ public Collection getImplementsTypes() { return List.of(Types.Client.Json.JsonEnum); } - public void addVariant(String value, boolean deprecated) { + public void addVariant(String value, String description, boolean deprecated) { var variant = variants.get(value.toLowerCase()); if (variant == null) { - variant = new Variant(value, deprecated); + variant = new Variant(value, description, deprecated); variants.put(value.toLowerCase(), variant); } else { variant.addAlias(value); variant.setDeprecated(variant.isDeprecated() || deprecated); + if (description != null) { + variant.setDescription(description); + } } } @@ -61,9 +66,11 @@ public static class Variant { private final String wireName; private final Set aliases = new HashSet<>(); private boolean deprecated; + private String description; - public Variant(String wireName, boolean deprecated) { + public Variant(String wireName, String description, boolean deprecated) { this.wireName = wireName; + setDescription(description); this.deprecated = deprecated; } @@ -71,6 +78,14 @@ public String getWireName() { return wireName; } + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description != null ? Markdown.toJavaDocHtml(description) : null; + } + public Set getAliases() { return aliases; } 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 3ecac3830d..9caa269bf5 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 @@ -21,6 +21,7 @@ public class ObjectShape extends Shape { protected final Map bodyFields = new TreeMap<>(); protected Field additionalPropertiesField; + private String shortcutProperty; public ObjectShape(Namespace parent, String className, String typedefName, String description) { super(parent, className, typedefName, description); @@ -62,6 +63,14 @@ public Field getAdditionalPropertiesField() { return additionalPropertiesField; } + public String getShortcutProperty() { + return shortcutProperty; + } + + public void setShortcutProperty(String shortcutProperty) { + this.shortcutProperty = shortcutProperty; + } + public boolean hasFieldsToSerialize() { return !bodyFields.isEmpty() || additionalPropertiesField != null; } @@ -108,6 +117,10 @@ public Collection getAnnotations() { return (hasFieldsToSerialize() || extendsOtherShape()) && !isAbstract() ? List.of(Types.Client.Json.JsonpDeserializable) : null; } + public boolean shouldImplementPlainDeserializable() { + return Set.of("SourceField", "TypeMapping").contains(getClassName()); + } + public static class ReferencingDiscriminatedUnion { private final TaggedUnionShape union; private final String discriminatorValue; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java index b9452504f1..55203856fb 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java @@ -28,6 +28,7 @@ import org.opensearch.client.codegen.model.overrides.Overrides; import org.opensearch.client.codegen.model.overrides.PropertyOverride; import org.opensearch.client.codegen.model.overrides.SchemaOverride; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; import org.opensearch.client.codegen.openapi.HttpStatusCode; import org.opensearch.client.codegen.openapi.In; import org.opensearch.client.codegen.openapi.JsonPointer; @@ -252,33 +253,25 @@ private Shape visit(Namespace parent, String className, String typedefName, Open var description = schema.getDescription().orElse(null); - var oneOf = schema.getOneOf(); - var isTaggedUnion = oneOf.isPresent() - && (schema.getDiscriminator().isPresent() || oneOf.orElseThrow().stream().allMatch(OpenApiSchema::hasTitle)); + var isTaggedUnion = isTaggedUnion(schema); + var isShortcutPropertyObject = isShortcutPropertyObject(schema); if (schema.isArray()) { shape = new ArrayShape(parent, className, mapType(schema), typedefName, description); visitedSchemas.putIfAbsent(schema, shape); - } else if (schema.isStringEnum() || (oneOf.isPresent() && oneOf.get().stream().allMatch(OpenApiSchema::isStringEnum))) { + } else if (isEnum(schema)) { var enumShape = new EnumShape(parent, className, typedefName, description); shape = enumShape; visitedSchemas.putIfAbsent(schema, shape); - if (oneOf.isPresent()) { - oneOf.get().forEach(s -> { - var isDeprecated = s.getVersionDeprecated().isPresent(); - s.getEnums().orElseThrow().forEach(v -> enumShape.addVariant(v, isDeprecated)); - }); - } else { - schema.getEnums().orElseThrow().forEach(v -> enumShape.addVariant(v, false)); - } + visitInto(schema, enumShape); } else if (isTaggedUnion) { var discriminatingField = schema.getDiscriminator().flatMap(OpenApiDiscriminator::getPropertyName).orElse(null); var taggedUnion = new TaggedUnionShape(parent, className, typedefName, description, discriminatingField); shape = taggedUnion; visitedSchemas.putIfAbsent(schema, shape); - oneOf.get().forEach(s -> { + schema.getOneOf().or(schema::getAnyOf).orElseThrow().forEach(s -> { String name; if (discriminatingField != null) { var props = new HashMap(); @@ -301,7 +294,7 @@ private Shape visit(Namespace parent, String className, String typedefName, Open } taggedUnion.addVariant(name, mapType(s)); }); - } else if (schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object) { + } else if (isShortcutPropertyObject || schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object) { if (schema.getProperties().isEmpty() && schema.getAdditionalProperties().isPresent()) { shape = new DictionaryResponseShape( parent, @@ -317,6 +310,13 @@ private Shape visit(Namespace parent, String className, String typedefName, Open shape = objShape; visitedSchemas.putIfAbsent(schema, shape); + if (isShortcutPropertyObject) { + var oneOf = schema.getOneOf().orElseThrow(); + var shortcutProperty = oneOf.get(0).getTitle().orElseThrow(); + objShape.setShortcutProperty(shortcutProperty); + schema = oneOf.get(1); + } + visitInto(schema, objShape); } } else { @@ -369,7 +369,7 @@ private void visitInto(OpenApiSchema schema, ObjectShape shape) { } } - private Set collectObjectProperties( + private static Set collectObjectProperties( OpenApiSchema schema, Map properties, List additionalProperties @@ -428,6 +428,21 @@ private Set collectObjectProperties( return schema.getRequired().orElseGet(Collections::emptySet); } + private void visitInto(OpenApiSchema schema, EnumShape shape) { + var isDeprecated = schema.getVersionDeprecated().isPresent(); + + if (schema.hasOneOf()) { + schema.getOneOf().orElseThrow().forEach(s -> visitInto(s, shape)); + } else if (schema.hasEnums()) { + var enums = schema.getEnums().orElseThrow(); + var description = enums.size() == 1 ? schema.getDescription().orElse(null) : null; + enums.forEach(v -> shape.addVariant(v, description, isDeprecated)); + } else if (schema.hasConst()) { + var value = (String) schema.getConst().orElseThrow(); + shape.addVariant(value, schema.getDescription().orElse(null), isDeprecated); + } + } + private Type mapType(OpenApiSchema schema) { return mapType(schema, false); } @@ -452,10 +467,26 @@ private Type mapTypeInner(OpenApiSchema schema) { if (schema.has$ref()) { schema = schema.resolve(); + var schemaOverrides = overrides.getSchema(schema.getPointer()); + var overriddenMappedType = schemaOverrides.flatMap(SchemaOverride::getMappedType); + + if (overriddenMappedType.isPresent()) { + return overriddenMappedType.get(); + } + if (!shouldKeepRef(schema)) { return mapType(schema); } + var shouldGenerate = schemaOverrides.map(SchemaOverride::shouldGenerate).orElse(ShouldGenerate.IfNeeded); + + if (shouldGenerate == ShouldGenerate.Never) { + return Type.builder() + .withPackage(Types.Client.OpenSearch.PACKAGE + "." + schema.getNamespace().orElseThrow()) + .withName(schema.getName().orElseThrow()) + .build(); + } + var shape = visit(schema); return shape.getType(); @@ -582,38 +613,24 @@ private boolean shouldKeepRef(OpenApiSchema schema) { if (schema.isArray() || schema.isBoolean() || schema.isInteger() || schema.isNumber()) { return false; } + if (isEnum(schema)) { + return true; + } if (schema.isString()) { - return schema.hasEnums(); + return false; } if (schema.isObject() && schema.getProperties().map(Map::isEmpty).orElse(true) && schema.getAdditionalProperties().map(s -> s.getTitle().isEmpty()).orElse(false)) { return false; } - if (schema.getOneOf().isPresent()) { - if (schema.getDiscriminator().isPresent()) { - return true; - } - var allObject = true; - var allHaveTitle = true; - var allStringEnum = true; - for (var s : schema.getOneOf().orElseThrow()) { - if (s.determineSingleType().orElse(null) != OpenApiSchemaType.Object) { - allObject = false; - } - if (s.getTitle().isEmpty()) { - allHaveTitle = false; - } - if (!s.isStringEnum()) { - allStringEnum = false; - } - } - return allObject || allHaveTitle || allStringEnum; + if (isTaggedUnion(schema)) { + return true; } - if (schema.getAllOf().isPresent()) { - return schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object; + if (isShortcutPropertyObject(schema)) { + return true; } - return true; + return schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object; } private static boolean isOneOfSingleAndArray(List oneOf) { @@ -628,4 +645,56 @@ private static boolean isOneOfSingleAndArray(List oneOf) { var items = second.getItems().orElseThrow(); return first.getTypes().equals(items.getTypes()) && first.get$ref().equals(items.get$ref()); } + + private static boolean isEnum(OpenApiSchema schema) { + if (schema.isString()) { + return schema.hasEnums() || schema.hasConst(); + } + if (schema.getOneOf().isPresent()) { + return schema.getOneOf().get().stream().allMatch(SpecTransformer::isEnum); + } + return false; + } + + private static boolean isShortcutPropertyObject(OpenApiSchema schema) { + var oneOf = schema.getOneOf().orElse(null); + + if (oneOf == null || oneOf.size() != 2) { + return false; + } + + var first = oneOf.get(0); + var second = oneOf.get(1); + + if (!first.hasTitle() || second.hasTitle()) { + return false; + } + + var secondType = second.determineSingleType().orElse(null); + if (secondType != OpenApiSchemaType.Object) { + return false; + } + + var properties = new HashMap(); + collectObjectProperties(second, properties, new ArrayList<>()); + + return properties.containsKey(first.getTitle().orElseThrow()); + } + + private static boolean isTaggedUnion(OpenApiSchema schema) { + if (schema.hasOneOf()) { + if (schema.getDiscriminator().isPresent()) { + return true; + } + return isTaggedUnion(schema.getOneOf().orElseThrow()); + } + if (schema.hasAnyOf()) { + return isTaggedUnion(schema.getAnyOf().orElseThrow()); + } + return false; + } + + private static boolean isTaggedUnion(List oneOfAnyOf) { + return oneOfAnyOf.stream().allMatch(OpenApiSchema::hasTitle); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java index 8e317e2ef8..907f745c5f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java @@ -36,10 +36,6 @@ public Collection getVariants() { return variants.values(); } - public Collection getShapeVariants() { - return Lists.filter(getVariants(), v -> v.getType().isInsidePackage("org.opensearch") && !v.getType().isEnum()); - } - public Collection getNonShapeVariants() { return Lists.filter(getVariants(), v -> !v.getType().isInsidePackage("org.opensearch")); } @@ -82,8 +78,9 @@ public boolean canStringify() { @Override public void render(ShapeRenderingContext ctx) throws RenderException { super.render(ctx); - if (!getShapeVariants().isEmpty()) { - new Builders(this).render(ctx); + var buildableVariants = Lists.filter(getVariants(), v -> v.getType().hasBuilder()); + if (!buildableVariants.isEmpty()) { + new Builders(this, buildableVariants).render(ctx); } if (isDiscriminated()) { new VariantInterface(this).render(ctx); @@ -130,9 +127,9 @@ private static String buildDescription(TaggedUnionShape union) { private final String unionClassName; private final Collection variants; - private Builders(TaggedUnionShape union) { + private Builders(TaggedUnionShape union, Collection variants) { super(union.getParent(), union.getClassName() + "Builders", null, buildDescription(union)); - variants = union.getShapeVariants(); + this.variants = variants; unionClassName = union.getClassName(); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java index 7545444777..79d82cc30c 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java @@ -142,6 +142,7 @@ public static final class Json { .withName("ObjectBuilderDeserializer") .build(); public static final Type ObjectDeserializer = Type.builder().withPackage(PACKAGE).withName("ObjectDeserializer").build(); + public static final Type PlainDeserializable = Type.builder().withPackage(PACKAGE).withName("PlainDeserializable").build(); public static final Type PlainJsonSerializable = Type.builder().withPackage(PACKAGE).withName("PlainJsonSerializable").build(); public static final Type UnionDeserializer = Type.builder().withPackage(PACKAGE).withName("UnionDeserializer").build(); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java index 7a8ef32339..750a4e8e88 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java @@ -12,10 +12,10 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.function.Function; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.opensearch.client.codegen.model.Types; import org.opensearch.client.codegen.openapi.JsonPointer; import org.opensearch.client.codegen.utils.builder.ObjectBuilder; import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; @@ -24,20 +24,16 @@ public class Overrides { private static final JsonPointer SCHEMAS = JsonPointer.of("components", "schemas"); public static final Overrides OVERRIDES = builder().withSchemas( - s -> s.with(SCHEMAS.append("_common.query_dsl:QueryContainer"), so -> so.withClassName("Query")) - .with(SCHEMAS.append("indices._common:IndexSettings"), so -> so.withAliasProvider((k) -> { - switch (k) { - case "index": - case "indexing": - case "mapping": - case "search": - case "settings": - case "top_metrics_max_size": - return null; - default: - return Set.of("index." + k); - } - })) + s -> s + // TODO: Remove this to generate property mapping types + .with(SCHEMAS.append("_common.mapping:Property"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + // TODO: Remove this to generate query types + .with( + SCHEMAS.append("_common.query_dsl:QueryContainer"), + so -> so.withMappedType(t -> t.withPackage(Types.Client.OpenSearch._Types.PACKAGE + ".query_dsl").withName("Query")) + ) + // TODO: Remove this to generate index settings types + .with(SCHEMAS.append("indices._common:IndexSettings"), so -> so.withShouldGenerate(ShouldGenerate.Never)) ).build(); @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java index a72db9173e..a1ee81b882 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java @@ -24,19 +24,22 @@ import org.opensearch.client.codegen.utils.builder.ObjectMapBuilderBase; public final class SchemaOverride { - private final boolean skipGeneration; + private final ShouldGenerate shouldGenerate; @Nonnull private final Map properties; @Nullable private final Function> aliasProvider; @Nullable private final String className; + @Nullable + private final Type mappedType; private SchemaOverride(Builder builder) { - this.skipGeneration = builder.skipGeneration; + this.shouldGenerate = builder.shouldGenerate; this.properties = builder.properties != null ? Collections.unmodifiableMap(builder.properties) : Collections.emptyMap(); this.aliasProvider = builder.aliasProvider; this.className = builder.className; + this.mappedType = builder.mappedType; } @Nonnull @@ -63,8 +66,8 @@ public PropertyOverride getProperty(@Nonnull String key) { return PropertyOverride.builder().withMappedType(mappedType).withAliases(aliases).build(); } - public boolean shouldSkipGeneration() { - return skipGeneration; + public ShouldGenerate shouldGenerate() { + return shouldGenerate; } @Nonnull @@ -72,6 +75,11 @@ public Optional getClassName() { return Optional.ofNullable(className); } + @Nonnull + public Optional getMappedType() { + return Optional.ofNullable(mappedType); + } + @Nonnull public static Builder builder() { return new Builder(); @@ -83,13 +91,16 @@ public static MapBuilder mapBuilder() { } public static final class Builder extends ObjectBuilderBase { - private boolean skipGeneration; + @Nonnull + private ShouldGenerate shouldGenerate = ShouldGenerate.IfNeeded; @Nullable private Map properties; @Nullable private Function> aliasProvider; @Nullable private String className; + @Nullable + private Type mappedType; private Builder() {} @@ -100,8 +111,8 @@ protected SchemaOverride construct() { } @Nonnull - public Builder withSkipGeneration(boolean skipGeneration) { - this.skipGeneration = skipGeneration; + public Builder withShouldGenerate(ShouldGenerate shouldGenerate) { + this.shouldGenerate = Objects.requireNonNull(shouldGenerate, "shouldGenerate must not be null"); return this; } @@ -122,6 +133,18 @@ public Builder withClassName(@Nullable String className) { this.className = className; return this; } + + @Nonnull + public Builder withMappedType(@Nullable Type mappedType) { + this.mappedType = mappedType; + return this; + } + + @Nonnull + public Builder withMappedType(@Nonnull Function> fn) { + this.mappedType = Objects.requireNonNull(fn, "fn must not be null").apply(Type.builder()).build(); + return this; + } } public static final class MapBuilder extends ObjectMapBuilderBase { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java new file mode 100644 index 0000000000..068511302c --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java @@ -0,0 +1,15 @@ +/* + * 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. + */ + +package org.opensearch.client.codegen.model.overrides; + +public enum ShouldGenerate { + Always, + IfNeeded, + Never +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java index 304b3e4055..79ca01555f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java @@ -68,6 +68,8 @@ public class OpenApiSchema extends OpenApiRefElement { @Nullable private final OpenApiDiscriminator discriminator; @Nullable + private final Object constValue; + @Nullable private final Semver versionRemoved; @Nullable private final Semver versionDeprecated; @@ -90,6 +92,7 @@ private OpenApiSchema(@Nonnull Builder builder) { title = builder.title; pattern = builder.pattern; discriminator = builder.discriminator; + constValue = builder.constValue; versionRemoved = builder.versionRemoved; versionDeprecated = builder.versionDeprecated; } @@ -144,6 +147,8 @@ protected OpenApiSchema(@Nullable OpenApiElement parent, @Nonnull JsonPointer discriminator = child("discriminator", schema.getDiscriminator(), OpenApiDiscriminator::new); + constValue = schema.getConst(); + var extensions = schema.getExtensions(); versionRemoved = Maps.tryGet(extensions, "x-version-removed").map(v -> Versions.coerce((String) v)).orElse(null); @@ -204,10 +209,6 @@ public boolean isString() { return is(OpenApiSchemaType.String); } - public boolean isStringEnum() { - return isString() && hasEnums(); - } - public boolean hasAllOf() { return allOf != null && !allOf.isEmpty(); } @@ -283,6 +284,15 @@ public Optional getDiscriminator() { return Optional.ofNullable(discriminator); } + public boolean hasConst() { + return constValue != null; + } + + @Nonnull + public Optional getConst() { + return Optional.ofNullable(constValue); + } + @Nonnull public Optional getVersionRemoved() { return Optional.ofNullable(versionRemoved); @@ -374,6 +384,8 @@ public static class Builder extends ObjectBuilderBase { @Nullable private OpenApiDiscriminator discriminator; @Nullable + private Object constValue; + @Nullable private Semver versionRemoved; @Nullable private Semver versionDeprecated; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java index 4f005f2a87..c8476f465b 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java @@ -8,6 +8,7 @@ package org.opensearch.client.codegen.utils; +import javax.annotation.Nonnull; import org.commonmark.parser.Parser; import org.commonmark.renderer.html.HtmlRenderer; @@ -17,7 +18,8 @@ private Markdown() {} private static final Parser PARSER = Parser.builder().build(); private static final HtmlRenderer RENDERER = HtmlRenderer.builder().omitSingleParagraphP(true).build(); - public static String toJavaDocHtml(String markdown) { + @Nonnull + public static String toJavaDocHtml(@Nonnull String markdown) { return RENDERER.render(PARSER.parse(markdown)).strip(); } } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache index 719c40ba20..543bfdb110 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache @@ -3,6 +3,11 @@ {{^-first}} {{/-first}} +{{#description}} + /** + * {{.}} + */ +{{/description}} {{#deprecated}} @Deprecated {{/deprecated}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache index f9a8abeeaa..f715bd75d5 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache @@ -4,7 +4,7 @@ */ {{#extendsOtherShape}} public static class Builder extends {{extendsType}}.AbstractBuilder - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{#shouldImplementPlainDeserializable}}, {{TYPES.Client.Json.PlainDeserializable}}{{/shouldImplementPlainDeserializable}} { {{>ObjectShape/Builder/Fields}} {{>ObjectShape/Builder/SelfImpl}} @@ -15,7 +15,8 @@ {{^extendsOtherShape}} {{#extendedByOtherShape}} public static class Builder extends {{type}}.AbstractBuilder - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}>{{#shouldImplementPlainDeserializable}}, {{TYPES.Client.Json.PlainDeserializable}}{{/shouldImplementPlainDeserializable}} + { {{>ObjectShape/Builder/SelfImpl}} {{>ObjectShape/Builder/BuildImpl}} @@ -23,7 +24,12 @@ {{/extendedByOtherShape}} {{^extendedByOtherShape}} public static class Builder extends {{TYPES.Client.Util.ObjectBuilderBase}} - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}>{{#shouldImplementPlainDeserializable}}, {{TYPES.Client.Json.PlainDeserializable}}{{/shouldImplementPlainDeserializable}} + { + {{#shouldImplementPlainDeserializable}} + {{>ObjectShape/Builder/SelfImpl}} + + {{/shouldImplementPlainDeserializable}} {{>ObjectShape/Builder/Fields}} {{>ObjectShape/Builder/BuildImpl}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache index 7d897fe252..ce3c4f49ed 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache @@ -1,4 +1,4 @@ @Override -protected Builder self() { +{{#shouldImplementPlainDeserializable}}public{{/shouldImplementPlainDeserializable}}{{^shouldImplementPlainDeserializable}}protected{{/shouldImplementPlainDeserializable}} Builder self() { return this; } \ No newline at end of file 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 ddb9adaddc..4d37bb6a2f 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 @@ -29,4 +29,8 @@ op.ignore({{#quoted}}{{key}}{{/quoted}}); {{/distinctDiscriminatorFieldValues}} + {{#shortcutProperty}} + + op.shortcutProperty({{#quoted}}{{.}}{{/quoted}}); + {{/shortcutProperty}} } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache index f0768a1e03..1f4eec4047 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache @@ -15,7 +15,16 @@ {{/type.isMap}} {{#type.isList}} for ({{type.listValueType}} item{{depth}} : {{value}}) { - {{#type.listValueType.serializer}}item{{depth}}{{/type.listValueType.serializer}} + {{#type.listValueType.isMap}} + generator.writeStartObject(); + if (item{{depth}} != null) { + {{#type.listValueType.directSerializer}}item{{depth}}{{/type.listValueType.directSerializer}} + } + generator.writeEnd(); + {{/type.listValueType.isMap}} + {{^type.listValueType.isMap}} + {{#type.listValueType.serializer}}item{{depth}}{{/type.listValueType.serializer}} + {{/type.listValueType.isMap}} } {{/type.isList}} {{^type.isListOrMap}}