From b7307264d974fe56a8bd52cd0ff91467dc96786c Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 7 Oct 2024 17:37:12 +1300 Subject: [PATCH] Begin generating indices.get Signed-off-by: Thomas Farr --- UPGRADING.md | 11 +- .../opensearch/OpenSearchAsyncClientBase.java | 5 + .../opensearch/OpenSearchClientBase.java | 5 + .../opensearch/_types/ExpandWildcard.java | 26 +- .../opensearch/_types/InlineScript.java | 78 +- .../client/opensearch/_types/Script.java | 42 +- .../client/opensearch/_types/ScriptBase.java | 52 +- .../opensearch/_types/ScriptBuilders.java | 11 +- .../opensearch/_types/ScriptLanguage.java | 67 + .../opensearch/_types/StoredScriptId.java | 36 +- .../opensearch/_types/mapping/AllField.java | 64 +- .../_types/mapping/DataStreamTimestamp.java | 146 ++ .../_types/mapping/DynamicMapping.java | 18 +- .../_types/mapping/DynamicTemplate.java | 63 +- .../_types/mapping/FieldNamesField.java | 30 +- .../opensearch/_types/mapping/IndexField.java | 30 +- .../opensearch/_types/mapping/MatchType.java | 12 +- .../_types/mapping/RoutingField.java | 30 +- .../_types/mapping/RuntimeField.java | 389 ++++ .../mapping/RuntimeFieldFetchFields.java} | 135 +- .../_types/mapping/RuntimeFieldType.java | 10 +- .../opensearch/_types/mapping/SizeField.java | 30 +- .../_types/mapping/SourceField.java | 100 +- .../_types/mapping/SourceFieldMode.java | 65 + .../_types/mapping/TypeMapping.java | 336 ++-- .../client/opensearch/indices/Alias.java | 202 +- .../opensearch/indices/GetIndexRequest.java | 266 +-- .../opensearch/indices/GetIndexResponse.java | 17 +- .../client/opensearch/indices/IndexState.java | 185 +- .../OpenSearchIndicesAsyncClientBase.java | 79 + .../indices/OpenSearchIndicesClientBase.java | 78 + .../opensearch/OpenSearchAsyncClient.java | 5 - .../client/opensearch/OpenSearchClient.java | 5 - .../indices/OpenSearchIndicesAsyncClient.java | 35 +- .../indices/OpenSearchIndicesClient.java | 35 +- java-codegen/opensearch-openapi.yaml | 1702 +++++++++++------ .../client/codegen/CodeGenerator.java | 1 + .../client/codegen/model/EnumShape.java | 21 +- .../client/codegen/model/ObjectShape.java | 4 + .../client/codegen/model/SpecTransformer.java | 64 +- .../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 | 8 +- .../templates/Type/directSerializer.mustache | 11 +- 49 files changed, 3243 insertions(+), 1374 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/InlineScript.java (74%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/Script.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/ScriptBase.java (71%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/ScriptBuilders.java (85%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/ScriptLanguage.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/StoredScriptId.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 (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/FieldNamesField.java (82%) 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%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/RuntimeField.java rename java-client/src/{main/java/org/opensearch/client/opensearch/_types/mapping/RuntimeField.java => generated/java/org/opensearch/client/opensearch/_types/mapping/RuntimeFieldFetchFields.java} (58%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/RuntimeFieldType.java (84%) 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 (78%) 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 (52%) 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..c4beb34b0d 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -51,4 +51,13 @@ 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. + +### indices.Alias +- The `indexRouting`, `routing` and `searchRouting` properties now accept a `List` instead of a `String`. + +### InlineScript +- The `lang` property now accepts a `ScriptLanguage` enum instead of a `String`. + +### DynamicMapping +- Removed the `Runtime` variant from the `DynamicMapping` enum 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/InlineScript.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/InlineScript.java similarity index 74% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineScript.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/InlineScript.java index be2177029b..26ff4f97bb 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineScript.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/InlineScript.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; 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,26 +54,28 @@ // typedef: _types.InlineScript @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class InlineScript extends ScriptBase { + @Nullable - private final String lang; + private final ScriptLanguage lang; + @Nonnull private final Map options; + @Nonnull private final String source; // --------------------------------------------------------------------------------------------- private InlineScript(Builder builder) { super(builder); - this.lang = builder.lang; this.options = ApiTypeHelper.unmodifiable(builder.options); this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); - } - public static InlineScript of(Function> fn) { + public static InlineScript of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -74,46 +83,48 @@ public static InlineScript of(Function> fn) * API name: {@code lang} */ @Nullable - public final String lang() { + public final ScriptLanguage lang() { return this.lang; } /** * API name: {@code options} */ + @Nonnull public final Map options() { return this.options; } /** - * Required - API name: {@code source} + * Required - The script source. + *

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

*/ + @Nonnull public final String source() { return this.source; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - super.serializeInternal(generator, mapper); if (this.lang != null) { generator.writeKey("lang"); - generator.write(this.lang); - + this.lang.serialize(generator, mapper); } + if (ApiTypeHelper.isDefined(this.options)) { generator.writeKey("options"); generator.writeStartObject(); for (Map.Entry item0 : this.options.entrySet()) { generator.writeKey(item0.getKey()); generator.write(item0.getValue()); - } generator.writeEnd(); - } + generator.writeKey("source"); generator.write(this.source); - } // --------------------------------------------------------------------------------------------- @@ -121,28 +132,27 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link InlineScript}. */ - public static class Builder extends ScriptBase.AbstractBuilder implements ObjectBuilder { @Nullable - private String lang; - + private ScriptLanguage lang; @Nullable private Map options; - private String source; /** * API name: {@code lang} */ - public final Builder lang(@Nullable String value) { + public final Builder lang(@Nullable ScriptLanguage value) { this.lang = value; return this; } /** * API name: {@code options} + * *

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

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

* Adds an entry to options. + *

*/ public final Builder options(String key, String value) { this.options = _mapPut(this.options, key, value); @@ -160,7 +172,10 @@ public final Builder options(String key, String value) { } /** - * Required - API name: {@code source} + * Required - The script source. + *

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

*/ public final Builder source(String value) { this.source = value; @@ -175,8 +190,7 @@ protected Builder self() { /** * Builds a {@link InlineScript}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public InlineScript build() { _checkSingleUse(); @@ -196,13 +210,27 @@ public InlineScript build() { ); protected static void setupInlineScriptDeserializer(ObjectDeserializer op) { - ScriptBase.setupScriptBaseDeserializer(op); - op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang"); + setupScriptBaseDeserializer(op); + op.add(Builder::lang, ScriptLanguage._DESERIALIZER, "lang"); op.add(Builder::options, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "options"); op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); + } - op.shortcutProperty("source"); - + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Objects.hashCode(this.lang); + result = 31 * result + Objects.hashCode(this.options); + result = 31 * result + this.source.hashCode(); + return result; } + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + InlineScript other = (InlineScript) o; + return Objects.equals(this.lang, other.lang) && Objects.equals(this.options, other.options) && this.source.equals(other.source); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Script.java similarity index 80% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/Script.java index 6f969b8f5a..bd42a231de 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Script.java @@ -30,14 +30,21 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; 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; import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.json.UnionDeserializer; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; @@ -48,12 +55,14 @@ // typedef: _types.Script @JsonpDeserializable -public class Script implements TaggedUnion, JsonpSerializable { - +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class Script implements TaggedUnion, PlainJsonSerializable { + /** + * {@link Script} variant kinds. + */ public enum Kind { Inline, Stored - } private final Kind _kind; @@ -75,13 +84,11 @@ private Script(Kind kind, Object value) { } private Script(Builder builder) { - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - } - public static Script of(Function> fn) { + public static Script of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -95,8 +102,7 @@ public boolean isInline() { /** * Get the {@code inline} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code inline} kind. + * @throws IllegalStateException if the current variant is not the {@code inline} kind. */ public InlineScript inline() { return TaggedUnionUtils.get(this, Kind.Inline); @@ -112,8 +118,7 @@ public boolean isStored() { /** * Get the {@code stored} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code stored} kind. + * @throws IllegalStateException if the current variant is not the {@code stored} kind. */ public StoredScriptId stored() { return TaggedUnionUtils.get(this, Kind.Stored); @@ -124,7 +129,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { if (_value instanceof JsonpSerializable) { ((JsonpSerializable) _value).serialize(generator, mapper); } - } public static class Builder extends ObjectBuilderBase implements ObjectBuilder