From 7446d50c98d6791309c2ad880a83fcff028148b5 Mon Sep 17 00:00:00 2001 From: Dan Cecoi Date: Wed, 7 Aug 2024 15:44:20 +0100 Subject: [PATCH 1/6] Removed the null constraints on NodeInfo.host, NodeInfo.Ip, NodeInfo.TransportAddress Signed-off-by: Dan Cecoi --- .../client/opensearch/nodes/info/NodeInfo.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/nodes/info/NodeInfo.java b/java-client/src/main/java/org/opensearch/client/opensearch/nodes/info/NodeInfo.java index 94df6b761c..ea9f2ef1a7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/nodes/info/NodeInfo.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/nodes/info/NodeInfo.java @@ -60,11 +60,13 @@ public class NodeInfo implements PlainJsonSerializable { private final String buildType; + @Nullable private final String host; @Nullable private final NodeInfoHttp http; + @Nullable private final String ip; @Nullable @@ -99,6 +101,7 @@ public class NodeInfo implements PlainJsonSerializable { @Nullable private final NodeInfoTransport transport; + @Nullable private final String transportAddress; private final String version; @@ -117,9 +120,9 @@ private NodeInfo(Builder builder) { this.attributes = ApiTypeHelper.unmodifiable(builder.attributes); this.buildHash = ApiTypeHelper.requireNonNull(builder.buildHash, this, "buildHash"); this.buildType = ApiTypeHelper.requireNonNull(builder.buildType, this, "buildType"); - this.host = ApiTypeHelper.requireNonNull(builder.host, this, "host"); + this.host = builder.host; this.http = builder.http; - this.ip = ApiTypeHelper.requireNonNull(builder.ip, this, "ip"); + this.ip = builder.ip; this.jvm = builder.jvm; this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.network = builder.network; @@ -132,7 +135,7 @@ private NodeInfo(Builder builder) { this.totalIndexingBuffer = builder.totalIndexingBuffer; this.totalIndexingBufferInBytes = builder.totalIndexingBufferInBytes; this.transport = builder.transport; - this.transportAddress = ApiTypeHelper.requireNonNull(builder.transportAddress, this, "transportAddress"); + this.transportAddress = builder.transportAddress; this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version"); this.modules = ApiTypeHelper.unmodifiable(builder.modules); this.ingest = builder.ingest; @@ -496,11 +499,13 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder * API name: {@code host} */ - public final Builder host(String value) { + public final Builder host(@Nullable String value) { this.host = value; return this; } @@ -618,7 +624,7 @@ public final Builder http(Function * API name: {@code ip} */ - public final Builder ip(String value) { + public final Builder ip(@Nullable String value) { this.ip = value; return this; } @@ -828,7 +834,7 @@ public final Builder transport(Function * API name: {@code transport_address} */ - public final Builder transportAddress(String value) { + public final Builder transportAddress(@Nullable String value) { this.transportAddress = value; return this; } From e28d42022047582966f8123c505487a85672d0bc Mon Sep 17 00:00:00 2001 From: Dan Cecoi Date: Thu, 8 Aug 2024 11:48:51 +0100 Subject: [PATCH 2/6] Added a CHANGELOG entry, made the getters nullable and removed extra white space Signed-off-by: Dan Cecoi --- CHANGELOG.md | 1 + .../opensearch/client/opensearch/nodes/info/NodeInfo.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f91dd824b5..fa87c9b1fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Fixed - Fixed error when deserializing a normalizer without 'type' ([#1111](https://github.com/opensearch-project/opensearch-java/pull/1111)) +- Removed null constraints on NodeInfo fields that are returned null from Amazon OpenSearch Service ([#1131](https://github.com/opensearch-project/opensearch-java/pull/1131)) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/nodes/info/NodeInfo.java b/java-client/src/main/java/org/opensearch/client/opensearch/nodes/info/NodeInfo.java index ea9f2ef1a7..4b97120434 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/nodes/info/NodeInfo.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/nodes/info/NodeInfo.java @@ -176,6 +176,7 @@ public final String buildType() { *

* API name: {@code host} */ + @Nullable public final String host() { return this.host; } @@ -193,6 +194,7 @@ public final NodeInfoHttp http() { *

* API name: {@code ip} */ + @Nullable public final String ip() { return this.ip; } @@ -302,6 +304,7 @@ public final NodeInfoTransport transport() { *

* API name: {@code transport_address} */ + @Nullable public final String transportAddress() { return this.transportAddress; } @@ -834,7 +837,7 @@ public final Builder transport(Function * API name: {@code transport_address} */ - public final Builder transportAddress(@Nullable String value) { + public final Builder transportAddress(@Nullable String value) { this.transportAddress = value; return this; } From 9794a2a7f3b1e813df703827ec0a5887c5298774 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Thu, 1 Aug 2024 09:31:43 +1200 Subject: [PATCH 3/6] Use own copy of PercentCodec for URI path encoding (#1109) * Use own copy of PercentCodec for URI path encoding Adapted from Apache HttpComponents HttpCore v5's https://github.com/apache/httpcomponents-core/blob/e009a923eefe79cf3593efbb0c18a3525ae63669/httpcore5/src/main/java/org/apache/hc/core5/net/PercentCodec.java Signed-off-by: Thomas Farr * Refactor PercentCodec a bit Signed-off-by: Thomas Farr * Add change log Signed-off-by: Thomas Farr * Switch to system property Signed-off-by: Thomas Farr * spotless Signed-off-by: Thomas Farr * Add UPGRADING note Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr --- CHANGELOG.md | 1 + UPGRADING.md | 5 +- .../transport/endpoints/SimpleEndpoint.java | 2 +- .../opensearch/client/util/PathEncoder.java | 72 +++---- .../opensearch/client/util/PercentCodec.java | 180 ++++++++++++++++++ .../client/opensearch/model/EndpointTest.java | 28 +-- .../client/util/PathEncoderTest.java | 44 ----- .../client/util/PercentCodecTest.java | 64 +++++++ 8 files changed, 281 insertions(+), 115 deletions(-) create mode 100644 java-client/src/main/java/org/opensearch/client/util/PercentCodec.java delete mode 100644 java-client/src/test/java/org/opensearch/client/util/PathEncoderTest.java create mode 100644 java-client/src/test/java/org/opensearch/client/util/PercentCodecTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index fa87c9b1fb..40637f9bd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Dependencies ### Changed +- Changed URL path encoding to own implementation adapted from Apache HTTP Client 5's ([#1109](https://github.com/opensearch-project/opensearch-java/pull/1109)) ### Deprecated diff --git a/UPGRADING.md b/UPGRADING.md index 4e437fa770..1b1a91c7c6 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,6 +1,9 @@ # UPGRADING -## [UPGRADING 2.x to 3.0] +## Upgrading 2.x to 3.0 +### URL Path Encoding +- The default URL path encoding has been changed to be more conservative. Previously the `!`, `$`, `&`, `'`, `(`, `)`, `*`, `+`, `,`, `;`, `=`, `@` and `:` characters were left un-encoded, they will now be percent-encoded. If you require the previous behavior you can specify the `org.opensearch.path.encoding=HTTP_CLIENT_V4_EQUIV` system property. + ### SearchAfter of SearchRequest type - Changed SearchAfter of SearchRequest type to FieldValue instead of String ([#769](https://github.com/opensearch-project/opensearch-java/pull/769)) - Consider using `FieldValue.of` to make string type values compatible. diff --git a/java-client/src/main/java/org/opensearch/client/transport/endpoints/SimpleEndpoint.java b/java-client/src/main/java/org/opensearch/client/transport/endpoints/SimpleEndpoint.java index 6409c845bc..f886c12ee7 100644 --- a/java-client/src/main/java/org/opensearch/client/transport/endpoints/SimpleEndpoint.java +++ b/java-client/src/main/java/org/opensearch/client/transport/endpoints/SimpleEndpoint.java @@ -133,6 +133,6 @@ public static RuntimeException noPathTemplateFound(String what) { } public static void pathEncode(String src, StringBuilder dest) { - dest.append(PathEncoder.encode(src)); + PathEncoder.encode(dest, src); } } diff --git a/java-client/src/main/java/org/opensearch/client/util/PathEncoder.java b/java-client/src/main/java/org/opensearch/client/util/PathEncoder.java index c9345a003f..5d43b7c19a 100644 --- a/java-client/src/main/java/org/opensearch/client/util/PathEncoder.java +++ b/java-client/src/main/java/org/opensearch/client/util/PathEncoder.java @@ -8,59 +8,43 @@ package org.opensearch.client.util; -/* - * 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. - */ - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Collections; +import java.util.Optional; public class PathEncoder { - private final static String HTTP_CLIENT4_UTILS_CLASS = "org.apache.http.client.utils.URLEncodedUtils"; - private final static String HTTP_CLIENT5_UTILS_CLASS = "org.apache.hc.core5.net.URLEncodedUtils"; - private final static MethodHandle FORMAT_SEGMENTS_MH; + private enum Encoding { + RFC3986_PATH(PercentCodec.RFC3986_PATH), + HTTP_CLIENT_V4_EQUIV(PercentCodec.RFC3986_PATH), + + RFC3986_UNRESERVED(PercentCodec.RFC3986_UNRESERVED), + HTTP_CLIENT_V5_EQUIV(PercentCodec.RFC3986_UNRESERVED); - static { - Class clazz = null; - try { - // Try Apache HttpClient5 first since this is a default one - clazz = Class.forName(HTTP_CLIENT5_UTILS_CLASS); - } catch (final ClassNotFoundException ex) { + private final PercentCodec percentCodec; + + Encoding(PercentCodec percentCodec) { + this.percentCodec = percentCodec; + } + + static Optional get(String name) { try { - // Fallback to Apache HttpClient4 - clazz = Class.forName(HTTP_CLIENT4_UTILS_CLASS); - } catch (final ClassNotFoundException ex1) { - clazz = null; + return Optional.of(Encoding.valueOf(name.toUpperCase())); + } catch (Exception ignored) { + return Optional.empty(); } } + } - if (clazz == null) { - throw new IllegalStateException( - "Either '" + HTTP_CLIENT5_UTILS_CLASS + "' or '" + HTTP_CLIENT4_UTILS_CLASS + "' is required by not found on classpath" - ); - } + private static final String ENCODING_PROPERTY = "org.opensearch.path.encoding"; + private static final Encoding ENCODING_DEFAULT = Encoding.HTTP_CLIENT_V5_EQUIV; - try { - FORMAT_SEGMENTS_MH = MethodHandles.lookup() - .findStatic(clazz, "formatSegments", MethodType.methodType(String.class, Iterable.class, Charset.class)); - } catch (final NoSuchMethodException | IllegalAccessException ex) { - throw new IllegalStateException("Unable to find 'formatSegments' method in " + clazz + " class"); - } + private static final Encoding ENCODING = Optional.ofNullable(System.getProperty(ENCODING_PROPERTY)) + .flatMap(Encoding::get) + .orElse(ENCODING_DEFAULT); + + public static String encode(String pathSegment) { + return ENCODING.percentCodec.encode(pathSegment); } - public static String encode(String uri) { - try { - return ((String) FORMAT_SEGMENTS_MH.invoke(Collections.singletonList(uri), StandardCharsets.UTF_8)).substring(1); - } catch (final Throwable ex) { - throw new RuntimeException("Unable to encode URI: " + uri, ex); - } + public static void encode(StringBuilder dest, CharSequence pathSegment) { + ENCODING.percentCodec.encode(dest, pathSegment); } } diff --git a/java-client/src/main/java/org/opensearch/client/util/PercentCodec.java b/java-client/src/main/java/org/opensearch/client/util/PercentCodec.java new file mode 100644 index 0000000000..9fb50637f9 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/util/PercentCodec.java @@ -0,0 +1,180 @@ +/* + * 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.util; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.BitSet; + +/** + * Percent-encoding. + *

+ * Adapted from Apache HttpComponents HttpCore v5's PercentCodec.java + *

+ */ +class PercentCodec { + private static class Chars { + private final BitSet set = new BitSet(256); + + public void add(char... chars) { + for (char c : chars) { + set.set(c); + } + } + + public void addRange(char start, char end) { + set.set(start, end + 1); + } + + public void add(Chars set) { + this.set.or(set.set); + } + + public boolean contains(int c) { + return set.get(c); + } + } + + private static final Chars RFC3986_GEN_DELIMS_CHARS = new Chars() { + { + add(':', '/', '?', '#', '[', ']', '@'); + } + }; + private static final Chars RFC3986_SUB_DELIMS_CHARS = new Chars() { + { + add('!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '='); + } + }; + private static final Chars RFC3986_UNRESERVED_CHARS = new Chars() { + { + addRange('a', 'z'); + addRange('A', 'Z'); + addRange('0', '9'); + add('-', '.', '_', '~'); + } + }; + private static final Chars RFC3986_PATH_NO_COLON_CHARS = new Chars() { + { + add(RFC3986_UNRESERVED_CHARS); + add(RFC3986_SUB_DELIMS_CHARS); + add('@'); + } + }; + private static final Chars RFC3986_PATH_CHARS = new Chars() { + { + add(RFC3986_PATH_NO_COLON_CHARS); + add(':'); + } + }; + private static final Chars RFC3986_URIC_CHARS = new Chars() { + { + add(RFC3986_SUB_DELIMS_CHARS); + add(RFC3986_UNRESERVED_CHARS); + } + }; + + private static final Chars RFC5987_UNRESERVED_CHARS = new Chars() { + { + addRange('a', 'z'); + addRange('A', 'Z'); + addRange('0', '9'); + // Additional characters as per RFC 5987 attr-char + add('!', '#', '$', '&', '+', '-', '.', '^', '_', '`', '|', '~'); + } + }; + + private static final int RADIX = 16; + + private static void encode( + final StringBuilder buf, + final CharSequence content, + final Charset charset, + final Chars safeChars, + final boolean blankAsPlus + ) { + if (content == null) { + return; + } + final CharBuffer cb = CharBuffer.wrap(content); + final ByteBuffer bb = (charset != null ? charset : StandardCharsets.UTF_8).encode(cb); + while (bb.hasRemaining()) { + final int b = bb.get() & 0xff; + if (safeChars.contains(b)) { + buf.append((char) b); + } else if (blankAsPlus && b == ' ') { + buf.append("+"); + } else { + buf.append("%"); + final char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX)); + final char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX)); + buf.append(hex1); + buf.append(hex2); + } + } + } + + private static String decode(final CharSequence content, final Charset charset, final boolean plusAsBlank) { + if (content == null) { + return null; + } + final ByteBuffer bb = ByteBuffer.allocate(content.length()); + final CharBuffer cb = CharBuffer.wrap(content); + while (cb.hasRemaining()) { + final char c = cb.get(); + if (c == '%' && cb.remaining() >= 2) { + final char uc = cb.get(); + final char lc = cb.get(); + final int u = Character.digit(uc, RADIX); + final int l = Character.digit(lc, RADIX); + if (u != -1 && l != -1) { + bb.put((byte) ((u << 4) + l)); + } else { + bb.put((byte) '%'); + bb.put((byte) uc); + bb.put((byte) lc); + } + } else if (plusAsBlank && c == '+') { + bb.put((byte) ' '); + } else { + bb.put((byte) c); + } + } + bb.flip(); + return (charset != null ? charset : StandardCharsets.UTF_8).decode(bb).toString(); + } + + public static final PercentCodec RFC3986_UNRESERVED = new PercentCodec(RFC3986_UNRESERVED_CHARS); + public static final PercentCodec RFC3986_PATH = new PercentCodec(RFC3986_PATH_CHARS); + public static final PercentCodec RFC5987_UNRESERVED = new PercentCodec(RFC5987_UNRESERVED_CHARS); + + private final Chars unreserved; + + private PercentCodec(final Chars unreserved) { + this.unreserved = unreserved; + } + + public void encode(final StringBuilder buf, final CharSequence content) { + encode(buf, content, StandardCharsets.UTF_8, unreserved, false); + } + + public String encode(final CharSequence content) { + if (content == null) { + return null; + } + final StringBuilder buf = new StringBuilder(); + encode(buf, content, StandardCharsets.UTF_8, unreserved, false); + return buf.toString(); + } + + public String decode(final CharSequence content) { + return decode(content, StandardCharsets.UTF_8, false); + } +} diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/model/EndpointTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/model/EndpointTest.java index b37f98622a..680f8ebe6d 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/model/EndpointTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/model/EndpointTest.java @@ -57,19 +57,10 @@ public void testArrayPathParameter() { assertEquals("/a/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); req = RefreshRequest.of(b -> b.index("a", "b")); - if (isHttpClient5Present()) { - assertEquals("/a%2Cb/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); - - } else { - assertEquals("/a,b/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); - } + assertEquals("/a%2Cb/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); req = RefreshRequest.of(b -> b.index("a", "b", "c")); - if (isHttpClient5Present()) { - assertEquals("/a%2Cb%2Cc/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); - } else { - assertEquals("/a,b,c/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); - } + assertEquals("/a%2Cb%2Cc/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); } @Test @@ -80,11 +71,7 @@ public void testPathEncoding() { assertEquals("/a%2Fb/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); req = RefreshRequest.of(b -> b.index("a/b", "c/d")); - if (isHttpClient5Present()) { - assertEquals("/a%2Fb%2Cc%2Fd/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); - } else { - assertEquals("/a%2Fb,c%2Fd/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); - } + assertEquals("/a%2Fb%2Cc%2Fd/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); } @@ -103,13 +90,4 @@ public void testArrayQueryParameter() { req = RefreshRequest.of(b -> b.expandWildcards(ExpandWildcard.All, ExpandWildcard.Closed)); assertEquals("all,closed", RefreshRequest._ENDPOINT.queryParameters(req).get("expand_wildcards")); } - - private static boolean isHttpClient5Present() { - try { - Class.forName("org.apache.hc.core5.net.URLEncodedUtils"); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } } diff --git a/java-client/src/test/java/org/opensearch/client/util/PathEncoderTest.java b/java-client/src/test/java/org/opensearch/client/util/PathEncoderTest.java deleted file mode 100644 index 0e0a5f8c15..0000000000 --- a/java-client/src/test/java/org/opensearch/client/util/PathEncoderTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.client.util; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class PathEncoderTest { - - @Test - public void testEncode() { - // Test with a simple string - String simpleString = "test"; - String encodedSimpleString = PathEncoder.encode(simpleString); - assertEquals(simpleString, encodedSimpleString); - - // Test with a string that contains special characters - String specialString = "a/b"; - String encodedSpecialString = PathEncoder.encode(specialString); - assertEquals("a%2Fb", encodedSpecialString); - - // Test with a string that contains alphanumeric characters - String alphanumericString = "abc123"; - String encodedAlphanumericString = PathEncoder.encode(alphanumericString); - assertEquals("abc123", encodedAlphanumericString); - - // Test with a string that contains multiple segments - String multiSegmentString = "a/b/c/_refresh"; - String encodedMultiSegmentString = PathEncoder.encode(multiSegmentString); - assertEquals("a%2Fb%2Fc%2F_refresh", encodedMultiSegmentString); - - // Test with a string that contains colon segment - String colonSegmentString = "a:b:c::2.0"; - String encodedColonSegmentString = PathEncoder.encode(colonSegmentString); - assertEquals("a%3Ab%3Ac%3A%3A2.0", encodedColonSegmentString); - } -} diff --git a/java-client/src/test/java/org/opensearch/client/util/PercentCodecTest.java b/java-client/src/test/java/org/opensearch/client/util/PercentCodecTest.java new file mode 100644 index 0000000000..7a13f69c58 --- /dev/null +++ b/java-client/src/test/java/org/opensearch/client/util/PercentCodecTest.java @@ -0,0 +1,64 @@ +/* + * 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.util; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.Collection; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class PercentCodecTest { + @Parameterized.Parameters + public static Collection testData() { + return Arrays.asList( + new Object[][] { + // , , + { "test", "test", "test" }, + { "abc123", "abc123", "abc123" }, + { "a/b", "a%2Fb", "a%2Fb" }, + { "a/b/c/_refresh", "a%2Fb%2Fc%2F_refresh", "a%2Fb%2Fc%2F_refresh" }, + { "a:b:c:d:e::1.0", "a%3Ab%3Ac%3Ad%3Ae%3A%3A1.0", "a:b:c:d:e::1.0" }, + { "a,b,c", "a%2Cb%2Cc", "a,b,c" } } + ); + } + + private final String decoded; + private final String encodedRFC3986Unreserved; + private final String encodedRFC3986Path; + + public PercentCodecTest(String decoded, String encodedRFC3986Unreserved, String encodedRFC3986Path) { + this.decoded = decoded; + this.encodedRFC3986Unreserved = encodedRFC3986Unreserved; + this.encodedRFC3986Path = encodedRFC3986Path; + } + + @Test + public void test_RFC3986_UNRESERVED_encoding() { + assertEquals(this.encodedRFC3986Unreserved, PercentCodec.RFC3986_UNRESERVED.encode(this.decoded)); + } + + @Test + public void test_RFC3986_UNRESERVED_decoding() { + assertEquals(this.decoded, PercentCodec.RFC3986_UNRESERVED.decode(this.encodedRFC3986Unreserved)); + } + + @Test + public void test_RFC3986_PATH_encoding() { + assertEquals(this.encodedRFC3986Path, PercentCodec.RFC3986_PATH.encode(this.decoded)); + } + + @Test + public void test_RFC3986_PATH_decoding() { + assertEquals(this.decoded, PercentCodec.RFC3986_PATH.decode(this.encodedRFC3986Path)); + } +} From eca99e0a6131311f0c262e1fe5be0ecb8ba35c87 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Thu, 1 Aug 2024 14:16:13 +1200 Subject: [PATCH 4/6] Fixed deserialization of SearchRequest when `_source` is an array (#1117) * Add failing test Signed-off-by: Thomas Farr * Fixed deserialization of SearchRequest when `_source` is an array Signed-off-by: Thomas Farr * Fix docker compose error Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr --- .github/workflows/test-integration.yml | 6 +- CHANGELOG.md | 1 + .../client/json/ObjectDeserializer.java | 7 +- .../client/json/UnionDeserializer.java | 9 ++- .../opensearch/core/SearchRequestTest.java | 75 +++++++++++++++++++ 5 files changed, 92 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 7758a38f12..07ad568359 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -41,8 +41,8 @@ jobs: - name: Run Docker run: | echo "PASSWORD=admin" >> $GITHUB_ENV - docker-compose --project-directory .ci/opensearch build --build-arg OPENSEARCH_VERSION=${{ matrix.entry.opensearch_version }} - docker-compose --project-directory .ci/opensearch up -d + docker compose --project-directory .ci/opensearch build --build-arg OPENSEARCH_VERSION=${{ matrix.entry.opensearch_version }} + docker compose --project-directory .ci/opensearch up -d sleep 60 - name: Sets password (new versions) @@ -64,4 +64,4 @@ jobs: - name: Stop Docker run: | - docker-compose --project-directory .ci/opensearch down \ No newline at end of file + docker compose --project-directory .ci/opensearch down \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 40637f9bd6..bf2bc4b9b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Fixed - Fixed error when deserializing a normalizer without 'type' ([#1111](https://github.com/opensearch-project/opensearch-java/pull/1111)) +- Fixed deserialization of SearchRequest when `_source` is an array ([#1117](https://github.com/opensearch-project/opensearch-java/pull/1117)) - Removed null constraints on NodeInfo fields that are returned null from Amazon OpenSearch Service ([#1131](https://github.com/opensearch-project/opensearch-java/pull/1131)) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/json/ObjectDeserializer.java b/java-client/src/main/java/org/opensearch/client/json/ObjectDeserializer.java index 316b0239e3..29655e35e4 100644 --- a/java-client/src/main/java/org/opensearch/client/json/ObjectDeserializer.java +++ b/java-client/src/main/java/org/opensearch/client/json/ObjectDeserializer.java @@ -239,7 +239,12 @@ public void shortcutProperty(String name) { throw new NoSuchElementException("No deserializer was setup for '" + name + "'"); } - acceptedEvents = EventSetObjectAndString; + this.acceptedEvents = EventSetObjectAndString.clone(); + + if (this.shortcutProperty instanceof FieldObjectDeserializer) { + JsonpDeserializer shortcutDeserializer = ((FieldObjectDeserializer) this.shortcutProperty).deserializer; + this.acceptedEvents.addAll(shortcutDeserializer.nativeEvents()); + } } // ----- Object types diff --git a/java-client/src/main/java/org/opensearch/client/json/UnionDeserializer.java b/java-client/src/main/java/org/opensearch/client/json/UnionDeserializer.java index 55527cefc0..8b190a9fa1 100644 --- a/java-client/src/main/java/org/opensearch/client/json/UnionDeserializer.java +++ b/java-client/src/main/java/org/opensearch/client/json/UnionDeserializer.java @@ -179,8 +179,13 @@ public Builder addMember(Kind tag, JsonpDeserializer member = new SingleMemberHandler<>(tag, deserializer); diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/core/SearchRequestTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/core/SearchRequestTest.java index bd0ca5186b..addeb30493 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/core/SearchRequestTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/core/SearchRequestTest.java @@ -9,9 +9,12 @@ package org.opensearch.client.opensearch.core; import java.util.Collections; +import java.util.List; import org.junit.Test; import org.opensearch.client.json.JsonData; import org.opensearch.client.opensearch._types.FieldValue; +import org.opensearch.client.opensearch.core.search.SourceConfig; +import org.opensearch.client.opensearch.core.search.SourceFilter; import org.opensearch.client.opensearch.model.ModelTestCase; public class SearchRequestTest extends ModelTestCase { @@ -57,4 +60,76 @@ public void toBuilder() { assertEquals(copied.index(), origin.index()); } + + @Test + public void canDeserializeSourceAsBoolean() { + String json = "{\"query\":{\"match_all\":{}},\"_source\":true,\"size\":1}"; + + SearchRequest searchRequest = fromJson(json, SearchRequest._DESERIALIZER); + + SourceConfig _source = searchRequest.source(); + assertNotNull(_source); + assertTrue(_source.isFetch()); + assertTrue(_source.fetch()); + } + + @Test + public void canDeserializeSourceAsString() { + String json = "{\"query\":{\"match_all\":{}},\"_source\":\"_id\",\"size\":1}"; + + SearchRequest searchRequest = fromJson(json, SearchRequest._DESERIALIZER); + + SourceConfig _source = searchRequest.source(); + assertNotNull(_source); + assertTrue(_source.isFilter()); + + SourceFilter filter = _source.filter(); + assertNotNull(filter); + + List includes = filter.includes(); + assertEquals(1, includes.size()); + assertEquals("_id", includes.get(0)); + + assertTrue(filter.excludes().isEmpty()); + } + + @Test + public void canDeserializeSourceAsArray() { + String json = "{\"query\":{\"match_all\":{}},\"_source\":[\"_id\"],\"size\":1}"; + + SearchRequest searchRequest = fromJson(json, SearchRequest._DESERIALIZER); + + SourceConfig _source = searchRequest.source(); + assertNotNull(_source); + assertTrue(_source.isFilter()); + + SourceFilter filter = _source.filter(); + assertNotNull(filter); + + List includes = filter.includes(); + assertEquals(1, includes.size()); + assertEquals("_id", includes.get(0)); + + assertTrue(filter.excludes().isEmpty()); + } + + @Test + public void canDeserializeSourceAsObject() { + String json = "{\"query\":{\"match_all\":{}},\"_source\":{\"includes\":[\"_id\"]},\"size\":1}"; + + SearchRequest searchRequest = fromJson(json, SearchRequest._DESERIALIZER); + + SourceConfig _source = searchRequest.source(); + assertNotNull(_source); + assertTrue(_source.isFilter()); + + SourceFilter filter = _source.filter(); + assertNotNull(filter); + + List includes = filter.includes(); + assertEquals(1, includes.size()); + assertEquals("_id", includes.get(0)); + + assertTrue(filter.excludes().isEmpty()); + } } From 8e0f00f0b34ded1d1581c2d0b6a0798d5f70be6e Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 6 Aug 2024 02:55:36 +1200 Subject: [PATCH 5/6] Regenerate dangling_indices namespace (#1124) * Rename genericArgs to typeParams Signed-off-by: Thomas Farr * Fix required path param handling Signed-off-by: Thomas Farr * Correctly generate AcknowledgedResponseBase Signed-off-by: Thomas Farr * Generate DeleteDanglingIndexRequest Signed-off-by: Thomas Farr * Correctly generate DeleteDanglingIndexResponse Signed-off-by: Thomas Farr * Generate import_dangling_index Signed-off-by: Thomas Farr * Generate ListDanglingIndicesRequest Signed-off-by: Thomas Farr * Generate ErrorCause Signed-off-by: Thomas Farr * Generate NodeStatistics Signed-off-by: Thomas Farr * Generate DanglingIndex Signed-off-by: Thomas Farr * Generate ListDanglingIndicesResponse Signed-off-by: Thomas Farr * Generate DanglingIndicesClient Signed-off-by: Thomas Farr * Fixes Signed-off-by: Thomas Farr * Changelog and Upgrading Signed-off-by: Thomas Farr * Fix javadoc Signed-off-by: Thomas Farr * Fix tests Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr --- CHANGELOG.md | 1 + UPGRADING.md | 3 + .../opensearch/OpenSearchAsyncClient.java | 10 + .../client/opensearch/OpenSearchClient.java | 10 + .../_types/AcknowledgedResponseBase.java | 27 +- .../client/opensearch/_types/ErrorCause.java | 265 +++---- .../opensearch/_types/NodeStatistics.java | 117 +-- .../_types/OpenSearchVersionInfo.java | 4 +- .../client/opensearch/core/InfoResponse.java | 6 +- .../DeleteDanglingIndexRequest.java | 150 ++-- .../DeleteDanglingIndexResponse.java | 19 +- .../ImportDanglingIndexRequest.java | 149 ++-- .../ImportDanglingIndexResponse.java | 19 +- .../ListDanglingIndicesRequest.java | 27 +- .../ListDanglingIndicesResponse.java | 105 ++- .../OpenSearchDanglingIndicesAsyncClient.java | 35 +- .../OpenSearchDanglingIndicesClient.java | 36 +- .../list_dangling_indices/DanglingIndex.java | 113 +-- .../opensearch/OpenSearchAsyncClientBase.java | 5 - .../opensearch/OpenSearchClientBase.java | 5 - .../json/PlainJsonSerializableTest.java | 2 +- .../opensearch/model/BehaviorsTest.java | 2 +- java-codegen/opensearch-openapi.yaml | 664 +++++++++++++++--- .../client/codegen/CodeGenerator.java | 2 +- .../client/codegen/model/ArrayShape.java | 2 +- .../client/codegen/model/Field.java | 13 + .../client/codegen/model/HttpPath.java | 4 +- .../client/codegen/model/Namespace.java | 10 +- .../client/codegen/model/ObjectShape.java | 12 +- .../client/codegen/model/RequestShape.java | 9 + .../client/codegen/model/Shape.java | 4 + .../client/codegen/model/SpecTransformer.java | 32 +- .../codegen/model/TaggedUnionShape.java | 2 +- .../opensearch/client/codegen/model/Type.java | 32 +- .../client/codegen/model/Types.java | 20 +- .../codegen/openapi/OpenApiRefElement.java | 5 + .../client/codegen/openapi/OpenApiSchema.java | 98 ++- .../codegen/templates/ObjectShape.mustache | 2 + .../templates/ObjectShape/Builder.mustache | 59 +- .../ObjectShape/Constructor.mustache | 12 +- .../ObjectShape/Deserialize.mustache | 10 +- .../ObjectShape/FieldDoc/BasicInner.mustache | 7 +- .../ObjectShape/FieldDoc/ListAdd.mustache | 1 + .../ObjectShape/FieldDoc/ListAddAll.mustache | 1 + .../FieldDoc/ListAddBuilderFn.mustache | 1 + .../templates/ObjectShape/Serialize.mustache | 2 + .../Partials/ClassDeclaration.mustache | 2 +- .../codegen/templates/RequestShape.mustache | 8 +- .../templates/Type/deserializer.mustache | 6 +- 49 files changed, 1436 insertions(+), 694 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java (87%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/ErrorCause.java (88%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/NodeStatistics.java (89%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexRequest.java (84%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java (86%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexRequest.java (84%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java (86%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesRequest.java (86%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java (67%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java (88%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java (87%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java (78%) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf2bc4b9b7..441725cac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Changed - Migrate client transports to Apache HttpClient / Core 5.x ([#246](https://github.com/opensearch-project/opensearch-java/pull/246)) - Changed SearchAfter of SearchRequest type to FieldValue instead of String ([#769](https://github.com/opensearch-project/opensearch-java/pull/769)) +- Changed type of `DanglingIndex`'s `creationDateMillis` field from `String` to `long` ([#1124](https://github.com/opensearch-project/opensearch-java/pull/1124)) ### Deprecated - Deprecate RestClientTransport ([#536](https://github.com/opensearch-project/opensearch-java/pull/536)) diff --git a/UPGRADING.md b/UPGRADING.md index 1b1a91c7c6..4764e323bf 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -21,3 +21,6 @@ After: .searchAfter(FieldValue.of("string1"), FieldValue.of("string2")) .searchAfter(List.of(FieldValue.of("String"))) ``` + +### DanglingIndex creationDateMillis type +- The type of `DanglingIndex`'s `creationDateMillis` field has been corrected from a `String` to a `long`. \ No newline at end of file diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java index 77f05da118..3c2dbdd206 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java @@ -43,9 +43,13 @@ import org.opensearch.client.opensearch._types.OpenSearchException; 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.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; +/** + * Client for the namespace. + */ @Generated("org.opensearch.client.codegen.CodeGenerator") public class OpenSearchAsyncClient extends OpenSearchAsyncClientBase { public OpenSearchAsyncClient(OpenSearchTransport transport) { @@ -61,6 +65,12 @@ public OpenSearchAsyncClient withTransportOptions(@Nullable TransportOptions tra return new OpenSearchAsyncClient(this.transport, transportOptions); } + // ----- Child clients + + public OpenSearchDanglingIndicesAsyncClient danglingIndices() { + return new OpenSearchDanglingIndicesAsyncClient(this.transport, this.transportOptions); + } + // ----- Endpoint: info /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java index 87e3cdc45a..d797bf2b54 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java @@ -42,9 +42,13 @@ import org.opensearch.client.opensearch._types.OpenSearchException; 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.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; +/** + * Client for the namespace. + */ @Generated("org.opensearch.client.codegen.CodeGenerator") public class OpenSearchClient extends OpenSearchClientBase { public OpenSearchClient(OpenSearchTransport transport) { @@ -60,6 +64,12 @@ public OpenSearchClient withTransportOptions(@Nullable TransportOptions transpor return new OpenSearchClient(this.transport, transportOptions); } + // ----- Child clients + + public OpenSearchDanglingIndicesClient danglingIndices() { + return new OpenSearchDanglingIndicesClient(this.transport, this.transportOptions); + } + // ----- Endpoint: info /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java similarity index 87% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java index 17037c3447..c7ab7d8510 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java @@ -30,9 +30,14 @@ * 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 javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.ObjectDeserializer; @@ -42,22 +47,22 @@ // typedef: _types.AcknowledgedResponseBase +@Generated("org.opensearch.client.codegen.CodeGenerator") public abstract class AcknowledgedResponseBase implements PlainJsonSerializable { + private final boolean acknowledged; // --------------------------------------------------------------------------------------------- protected AcknowledgedResponseBase(AbstractBuilder builder) { - this.acknowledged = ApiTypeHelper.requireNonNull(builder.acknowledged, this, "acknowledged"); - } /** - * Required - For a successful response, this value is always true. On failure, - * an exception is returned instead. + * Required - For a successful response, this value is always true. On failure, an exception is returned instead. *

* API name: {@code acknowledged} + *

*/ public final boolean acknowledged() { return this.acknowledged; @@ -66,6 +71,7 @@ public final boolean acknowledged() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -73,20 +79,21 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("acknowledged"); generator.write(this.acknowledged); } + // --------------------------------------------------------------------------------------------- + protected abstract static class AbstractBuilder> extends ObjectBuilderBase { private Boolean acknowledged; /** - * Required - For a successful response, this value is always true. On failure, - * an exception is returned instead. + * Required - For a successful response, this value is always true. On failure, an exception is returned instead. *

* API name: {@code acknowledged} + *

*/ public final BuilderT acknowledged(boolean value) { this.acknowledged = value; @@ -94,16 +101,12 @@ public final BuilderT acknowledged(boolean value) { } protected abstract BuilderT self(); - } - // --------------------------------------------------------------------------------------------- + protected static > void setupAcknowledgedResponseBaseDeserializer( ObjectDeserializer op ) { - op.add(AbstractBuilder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); - } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorCause.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java similarity index 88% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorCause.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java index 131f7046e5..2941b7ea30 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorCause.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java @@ -30,6 +30,10 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; import jakarta.json.stream.JsonGenerator; @@ -37,6 +41,7 @@ import java.util.List; import java.util.Map; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -51,78 +56,74 @@ // typedef: _types.ErrorCause -/** - * Cause and details about a request failure. This class defines the properties - * common to all error types. Additional details are also provided, that depend - * on the error type. - */ @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class ErrorCause implements PlainJsonSerializable { - private final Map metadata; - private final String type; + @Nullable + private final ErrorCause causedBy; + @Nullable private final String reason; + private final List rootCause; + @Nullable private final String stackTrace; - @Nullable - private final ErrorCause causedBy; + private final List suppressed; - private final List rootCause; + private final String type; - private final List suppressed; + private final Map metadata; // --------------------------------------------------------------------------------------------- private ErrorCause(Builder builder) { - - this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); - - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason"); - this.stackTrace = builder.stackTrace; this.causedBy = builder.causedBy; + this.reason = builder.reason; this.rootCause = ApiTypeHelper.unmodifiable(builder.rootCause); + this.stackTrace = builder.stackTrace; this.suppressed = ApiTypeHelper.unmodifiable(builder.suppressed); - + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); } - public static ErrorCause of(Function> fn) { + public static ErrorCause of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Additional details about the error + * API name: {@code caused_by} */ - public final Map metadata() { - return this.metadata; + @Nullable + public final ErrorCause causedBy() { + return this.causedBy; } /** - * Required - The type of error + * A human-readable explanation of the error, in english *

- * API name: {@code type} + * API name: {@code reason} + *

*/ - public final String type() { - return this.type; + @Nullable + public final String reason() { + return this.reason; } /** - * Required - A human-readable explanation of the error, in english - *

- * API name: {@code reason} + * API name: {@code root_cause} */ - public final String reason() { - return this.reason; + public final List rootCause() { + return this.rootCause; } /** - * The server stack trace. Present only if the error_trace=true - * parameter was sent with the request. + * The server stack trace. Present only if the `error_trace=true` parameter was sent with the request. *

* API name: {@code stack_trace} + *

*/ @Nullable public final String stackTrace() { @@ -130,30 +131,33 @@ public final String stackTrace() { } /** - * API name: {@code caused_by} + * API name: {@code suppressed} */ - @Nullable - public final ErrorCause causedBy() { - return this.causedBy; + public final List suppressed() { + return this.suppressed; } /** - * API name: {@code root_cause} + * Required - The type of error + *

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

*/ - public final List rootCause() { - return this.rootCause; + public final String type() { + return this.type; } /** - * API name: {@code suppressed} + * Additional details about the error */ - public final List suppressed() { - return this.suppressed; + public final Map metadata() { + return this.metadata; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -161,29 +165,24 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - for (Map.Entry item0 : this.metadata.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } - generator.writeKey("type"); - generator.write(this.type); - - generator.writeKey("reason"); - generator.write(this.reason); - - if (this.stackTrace != null) { - generator.writeKey("stack_trace"); - generator.write(this.stackTrace); - - } if (this.causedBy != null) { generator.writeKey("caused_by"); this.causedBy.serialize(generator, mapper); } + + if (this.reason != null) { + generator.writeKey("reason"); + generator.write(this.reason); + + } + if (ApiTypeHelper.isDefined(this.rootCause)) { generator.writeKey("root_cause"); generator.writeStartArray(); @@ -194,6 +193,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } + + if (this.stackTrace != null) { + generator.writeKey("stack_trace"); + generator.write(this.stackTrace); + + } + if (ApiTypeHelper.isDefined(this.suppressed)) { generator.writeKey("suppressed"); generator.writeStartArray(); @@ -205,6 +211,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } + generator.writeKey("type"); + generator.write(this.type); + } // --------------------------------------------------------------------------------------------- @@ -212,97 +221,53 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link ErrorCause}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private Map metadata = new HashMap<>(); - - /** - * Additional details about the error - *

- * Adds all entries of map to metadata. - */ - public final Builder metadata(Map map) { - this.metadata = _mapPutAll(this.metadata, map); - return this; - } - - /** - * Additional details about the error - *

- * Adds an entry to metadata. - */ - public final Builder metadata(String key, JsonData value) { - this.metadata = _mapPut(this.metadata, key, value); - return this; - } - - private String type; - - private String reason; - - @Nullable - private String stackTrace; - @Nullable private ErrorCause causedBy; - + @Nullable + private String reason; @Nullable private List rootCause; - + @Nullable + private String stackTrace; @Nullable private List suppressed; + private String type; + @Nullable + private Map metadata; /** - * Required - The type of error - *

- * API name: {@code type} + * API name: {@code caused_by} */ - public final Builder type(String value) { - this.type = value; + public final Builder causedBy(@Nullable ErrorCause value) { + this.causedBy = value; return this; } /** - * Required - A human-readable explanation of the error, in english - *

- * API name: {@code reason} + * API name: {@code caused_by} */ - public final Builder reason(String value) { - this.reason = value; - return this; + public final Builder causedBy(Function> fn) { + return causedBy(fn.apply(new ErrorCause.Builder()).build()); } /** - * The server stack trace. Present only if the error_trace=true - * parameter was sent with the request. + * A human-readable explanation of the error, in english *

- * API name: {@code stack_trace} - */ - public final Builder stackTrace(@Nullable String value) { - this.stackTrace = value; - return this; - } - - /** - * API name: {@code caused_by} + * API name: {@code reason} + *

*/ - public final Builder causedBy(@Nullable ErrorCause value) { - this.causedBy = value; + public final Builder reason(@Nullable String value) { + this.reason = value; return this; } - /** - * API name: {@code caused_by} - */ - public final Builder causedBy(Function> fn) { - return this.causedBy(fn.apply(new ErrorCause.Builder()).build()); - } - /** * API name: {@code root_cause} + * *

* Adds all elements of list to rootCause. + *

*/ public final Builder rootCause(List list) { this.rootCause = _listAddAll(this.rootCause, list); @@ -311,8 +276,10 @@ public final Builder rootCause(List list) { /** * API name: {@code root_cause} + * *

* Adds one or more values to rootCause. + *

*/ public final Builder rootCause(ErrorCause value, ErrorCause... values) { this.rootCause = _listAdd(this.rootCause, value, values); @@ -321,17 +288,32 @@ public final Builder rootCause(ErrorCause value, ErrorCause... values) { /** * API name: {@code root_cause} + * *

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

*/ public final Builder rootCause(Function> fn) { return rootCause(fn.apply(new ErrorCause.Builder()).build()); } + /** + * The server stack trace. Present only if the `error_trace=true` parameter was sent with the request. + *

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

+ */ + public final Builder stackTrace(@Nullable String value) { + this.stackTrace = value; + return this; + } + /** * API name: {@code suppressed} + * *

* Adds all elements of list to suppressed. + *

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

* Adds one or more values to suppressed. + *

*/ public final Builder suppressed(ErrorCause value, ErrorCause... values) { this.suppressed = _listAdd(this.suppressed, value, values); @@ -350,18 +334,46 @@ public final Builder suppressed(ErrorCause value, ErrorCause... values) { /** * API name: {@code suppressed} + * *

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

*/ public final Builder suppressed(Function> fn) { return suppressed(fn.apply(new ErrorCause.Builder()).build()); } + /** + * Required - The type of error + *

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

+ */ + public final Builder type(String value) { + this.type = value; + return this; + } + + /** + * Additional details about the error + */ + public final Builder metadata(Map map) { + this.metadata = _mapPutAll(this.metadata, map); + return this; + } + + /** + * Additional details about the error + */ + public final Builder metadata(String key, JsonData value) { + this.metadata = _mapPut(this.metadata, key, value); + return this; + } + /** * Builds a {@link ErrorCause}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public ErrorCause build() { _checkSingleUse(); @@ -369,7 +381,6 @@ public ErrorCause build() { return new ErrorCause(this); } } - // --------------------------------------------------------------------------------------------- /** @@ -381,21 +392,17 @@ public ErrorCause build() { ); protected static void setupErrorCauseDeserializer(ObjectDeserializer op) { - - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - op.add(Builder::reason, JsonpDeserializer.stringDeserializer(), "reason"); - op.add(Builder::stackTrace, JsonpDeserializer.stringDeserializer(), "stack_trace"); op.add(Builder::causedBy, ErrorCause._DESERIALIZER, "caused_by"); + op.add(Builder::reason, JsonpDeserializer.stringDeserializer(), "reason"); op.add(Builder::rootCause, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "root_cause"); + op.add(Builder::stackTrace, JsonpDeserializer.stringDeserializer(), "stack_trace"); op.add(Builder::suppressed, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "suppressed"); - + op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); op.setUnknownFieldHandler((builder, name, parser, mapper) -> { if (builder.metadata == null) { builder.metadata = new HashMap<>(); } builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); }); - } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeStatistics.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeStatistics.java similarity index 89% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeStatistics.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeStatistics.java index 94f7e0ae83..12b40c0fe4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeStatistics.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeStatistics.java @@ -30,11 +30,16 @@ * 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.List; 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; @@ -49,69 +54,72 @@ // typedef: _types.NodeStatistics @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class NodeStatistics implements PlainJsonSerializable { - private final List failures; - private final int total; + private final int failed; + + private final List failures; private final int successful; - private final int failed; + private final int total; // --------------------------------------------------------------------------------------------- private NodeStatistics(Builder builder) { - + this.failed = ApiTypeHelper.requireNonNull(builder.failed, this, "failed"); this.failures = ApiTypeHelper.unmodifiable(builder.failures); - this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); this.successful = ApiTypeHelper.requireNonNull(builder.successful, this, "successful"); - this.failed = ApiTypeHelper.requireNonNull(builder.failed, this, "failed"); - + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); } - public static NodeStatistics of(Function> fn) { + public static NodeStatistics of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * API name: {@code failures} + * Required - Number of nodes that rejected the request or failed to respond. If this value is not 0, a reason for the rejection or + * failure is included in the response. + *

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

*/ - public final List failures() { - return this.failures; + public final int failed() { + return this.failed; } /** - * Required - Total number of nodes selected by the request. - *

- * API name: {@code total} + * API name: {@code failures} */ - public final int total() { - return this.total; + public final List failures() { + return this.failures; } /** * Required - Number of nodes that responded successfully to the request. *

* API name: {@code successful} + *

*/ public final int successful() { return this.successful; } /** - * Required - Number of nodes that rejected the request or failed to respond. If - * this value is not 0, a reason for the rejection or failure is included in the - * response. + * Required - Total number of nodes selected by the request. *

- * API name: {@code failed} + * API name: {@code total} + *

*/ - public final int failed() { - return this.failed; + public final int total() { + return this.total; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -119,6 +127,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("failed"); + generator.write(this.failed); if (ApiTypeHelper.isDefined(this.failures)) { generator.writeKey("failures"); @@ -130,14 +140,12 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } - generator.writeKey("total"); - generator.write(this.total); generator.writeKey("successful"); generator.write(this.successful); - generator.writeKey("failed"); - generator.write(this.failed); + generator.writeKey("total"); + generator.write(this.total); } @@ -146,21 +154,31 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link NodeStatistics}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Integer failed; @Nullable private List failures; - - private Integer total; - private Integer successful; + private Integer total; - private Integer failed; + /** + * Required - Number of nodes that rejected the request or failed to respond. If this value is not 0, a reason for the rejection or + * failure is included in the response. + *

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

+ */ + public final Builder failed(int value) { + this.failed = value; + return this; + } /** * API name: {@code failures} + * *

* Adds all elements of list to failures. + *

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

* Adds one or more values to failures. + *

*/ public final Builder failures(ErrorCause value, ErrorCause... values) { this.failures = _listAdd(this.failures, value, values); @@ -179,27 +199,20 @@ public final Builder failures(ErrorCause value, ErrorCause... values) { /** * API name: {@code failures} + * *

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

*/ public final Builder failures(Function> fn) { return failures(fn.apply(new ErrorCause.Builder()).build()); } - /** - * Required - Total number of nodes selected by the request. - *

- * API name: {@code total} - */ - public final Builder total(int value) { - this.total = value; - return this; - } - /** * Required - Number of nodes that responded successfully to the request. *

* API name: {@code successful} + *

*/ public final Builder successful(int value) { this.successful = value; @@ -207,22 +220,20 @@ public final Builder successful(int value) { } /** - * Required - Number of nodes that rejected the request or failed to respond. If - * this value is not 0, a reason for the rejection or failure is included in the - * response. + * Required - Total number of nodes selected by the request. *

- * API name: {@code failed} + * API name: {@code total} + *

*/ - public final Builder failed(int value) { - this.failed = value; + public final Builder total(int value) { + this.total = value; return this; } /** * Builds a {@link NodeStatistics}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public NodeStatistics build() { _checkSingleUse(); @@ -230,7 +241,6 @@ public NodeStatistics build() { return new NodeStatistics(this); } } - // --------------------------------------------------------------------------------------------- /** @@ -242,12 +252,9 @@ public NodeStatistics build() { ); protected static void setupNodeStatisticsDeserializer(ObjectDeserializer op) { - + op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed"); op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "failures"); - op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); - op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed"); - + op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); } - } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java index 2de1706223..fe6603175b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java @@ -43,9 +43,9 @@ 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.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; @@ -54,7 +54,7 @@ @JsonpDeserializable @Generated("org.opensearch.client.codegen.CodeGenerator") -public class OpenSearchVersionInfo implements JsonpSerializable { +public class OpenSearchVersionInfo implements PlainJsonSerializable { private final String buildDate; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/core/InfoResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/core/InfoResponse.java index a8afc4e71d..08293ca62a 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/core/InfoResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/core/InfoResponse.java @@ -42,9 +42,9 @@ 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.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.opensearch._types.OpenSearchVersionInfo; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; @@ -54,7 +54,7 @@ @JsonpDeserializable @Generated("org.opensearch.client.codegen.CodeGenerator") -public class InfoResponse implements JsonpSerializable { +public class InfoResponse implements PlainJsonSerializable { private final String clusterName; @@ -199,7 +199,7 @@ public final Builder version(OpenSearchVersionInfo value) { * Required - API name: {@code version} */ public final Builder version(Function> fn) { - return this.version(fn.apply(new OpenSearchVersionInfo.Builder()).build()); + return version(fn.apply(new OpenSearchVersionInfo.Builder()).build()); } /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexRequest.java similarity index 84% rename from java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexRequest.java index 6a17b033b8..4f6ea2ac3c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexRequest.java @@ -30,11 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.dangling_indices; import java.util.HashMap; import java.util.Map; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; @@ -48,38 +53,38 @@ // typedef: dangling_indices.delete_dangling_index.Request /** - * Deletes the specified dangling index - * + * Deletes the specified dangling index. */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class DeleteDanglingIndexRequest extends RequestBase { + private final boolean acceptDataLoss; + @Nullable + private final Time clusterManagerTimeout; + private final String indexUuid; @Deprecated @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - @Nullable private final Time timeout; // --------------------------------------------------------------------------------------------- private DeleteDanglingIndexRequest(Builder builder) { - this.acceptDataLoss = ApiTypeHelper.requireNonNull(builder.acceptDataLoss, this, "acceptDataLoss"); + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.indexUuid = ApiTypeHelper.requireNonNull(builder.indexUuid, this, "indexUuid"); this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.timeout = builder.timeout; - } - public static DeleteDanglingIndexRequest of(Function> fn) { + public static DeleteDanglingIndexRequest of( + Function> fn + ) { return fn.apply(new Builder()).build(); } @@ -87,15 +92,28 @@ public static DeleteDanglingIndexRequest of(Function * API name: {@code accept_data_loss} + *

*/ public final boolean acceptDataLoss() { return this.acceptDataLoss; } + /** + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + /** * Required - The UUID of the dangling index *

* API name: {@code index_uuid} + *

*/ public final String indexUuid() { return this.indexUuid; @@ -105,26 +123,19 @@ public final String indexUuid() { * Specify timeout for connection to master *

* API name: {@code master_timeout} + *

*/ + @Deprecated @Nullable public final Time masterTimeout() { return this.masterTimeout; } - /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - /** * Explicit operation timeout *

* API name: {@code timeout} + *

*/ @Nullable public final Time timeout() { @@ -136,19 +147,13 @@ public final Time timeout() { /** * Builder for {@link DeleteDanglingIndexRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean acceptDataLoss; - + @Nullable + private Time clusterManagerTimeout; private String indexUuid; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - @Nullable private Time timeout; @@ -156,16 +161,39 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder * API name: {@code accept_data_loss} + *

*/ public final Builder acceptDataLoss(boolean value) { this.acceptDataLoss = value; return this; } + /** + * 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()); + } + /** * Required - The UUID of the dangling index *

* API name: {@code index_uuid} + *

*/ public final Builder indexUuid(String value) { this.indexUuid = value; @@ -176,6 +204,7 @@ public final Builder indexUuid(String value) { * Specify timeout for connection to master *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(@Nullable Time value) { @@ -187,35 +216,18 @@ public final Builder masterTimeout(@Nullable Time value) { * Specify timeout for connection to master *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; - return this; - } - - /** - * Specify timeout for connection to cluster-manager - *

- * 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()); } /** * Explicit operation timeout *

* API name: {@code timeout} + *

*/ public final Builder timeout(@Nullable Time value) { this.timeout = value; @@ -226,16 +238,16 @@ public final Builder timeout(@Nullable Time value) { * Explicit operation timeout *

* API name: {@code timeout} + *

*/ public final Builder timeout(Function> fn) { - return this.timeout(fn.apply(new Time.Builder()).build()); + return timeout(fn.apply(new Time.Builder()).build()); } /** * Builds a {@link DeleteDanglingIndexRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public DeleteDanglingIndexRequest build() { _checkSingleUse(); @@ -250,47 +262,29 @@ public DeleteDanglingIndexRequest build() { * Endpoint "{@code dangling_indices.delete_dangling_index}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "DELETE"; - - }, - + request -> "DELETE", // Request path request -> { - final int _indexUuid = 1 << 0; - - int propsSet = 0; - - propsSet |= _indexUuid; - - if (propsSet == (_indexUuid)) { - StringBuilder buf = new StringBuilder(); - buf.append("/_dangling"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.indexUuid, buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_dangling/"); + SimpleEndpoint.pathEncode(request.indexUuid, buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); - } + params.put("accept_data_loss", String.valueOf(request.acceptDataLoss)); if (request.clusterManagerTimeout != null) { params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); } - params.put("accept_data_loss", String.valueOf(request.acceptDataLoss)); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } return params; - }, SimpleEndpoint.emptyMap(), false, diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java similarity index 86% rename from java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java index f2e55aa97b..72f04f6cb1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java @@ -30,9 +30,14 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.dangling_indices; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; @@ -43,15 +48,18 @@ // typedef: dangling_indices.delete_dangling_index.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class DeleteDanglingIndexResponse extends AcknowledgedResponseBase { + // --------------------------------------------------------------------------------------------- private DeleteDanglingIndexResponse(Builder builder) { super(builder); - } - public static DeleteDanglingIndexResponse of(Function> fn) { + public static DeleteDanglingIndexResponse of( + Function> fn + ) { return fn.apply(new Builder()).build(); } @@ -60,7 +68,6 @@ public static DeleteDanglingIndexResponse of(Function implements ObjectBuilder { @@ -72,8 +79,7 @@ protected Builder self() { /** * Builds a {@link DeleteDanglingIndexResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public DeleteDanglingIndexResponse build() { _checkSingleUse(); @@ -81,7 +87,6 @@ public DeleteDanglingIndexResponse build() { return new DeleteDanglingIndexResponse(this); } } - // --------------------------------------------------------------------------------------------- /** @@ -94,7 +99,5 @@ public DeleteDanglingIndexResponse build() { protected static void setupDeleteDanglingIndexResponseDeserializer(ObjectDeserializer op) { AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); - } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexRequest.java similarity index 84% rename from java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexRequest.java index e0635576b9..4b1440b7eb 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexRequest.java @@ -30,11 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.dangling_indices; import java.util.HashMap; import java.util.Map; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; @@ -48,38 +53,38 @@ // typedef: dangling_indices.import_dangling_index.Request /** - * Imports the specified dangling index - * + * Imports the specified dangling index. */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class ImportDanglingIndexRequest extends RequestBase { + private final boolean acceptDataLoss; + @Nullable + private final Time clusterManagerTimeout; + private final String indexUuid; @Deprecated @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - @Nullable private final Time timeout; // --------------------------------------------------------------------------------------------- private ImportDanglingIndexRequest(Builder builder) { - this.acceptDataLoss = ApiTypeHelper.requireNonNull(builder.acceptDataLoss, this, "acceptDataLoss"); + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.indexUuid = ApiTypeHelper.requireNonNull(builder.indexUuid, this, "indexUuid"); this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.timeout = builder.timeout; - } - public static ImportDanglingIndexRequest of(Function> fn) { + public static ImportDanglingIndexRequest of( + Function> fn + ) { return fn.apply(new Builder()).build(); } @@ -87,15 +92,28 @@ public static ImportDanglingIndexRequest of(Function * API name: {@code accept_data_loss} + *

*/ public final boolean acceptDataLoss() { return this.acceptDataLoss; } + /** + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + /** * Required - The UUID of the dangling index *

* API name: {@code index_uuid} + *

*/ public final String indexUuid() { return this.indexUuid; @@ -105,6 +123,7 @@ public final String indexUuid() { * Specify timeout for connection to master *

* API name: {@code master_timeout} + *

*/ @Deprecated @Nullable @@ -112,20 +131,11 @@ public final Time masterTimeout() { return this.masterTimeout; } - /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - /** * Explicit operation timeout *

* API name: {@code timeout} + *

*/ @Nullable public final Time timeout() { @@ -137,19 +147,13 @@ public final Time timeout() { /** * Builder for {@link ImportDanglingIndexRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean acceptDataLoss; - + @Nullable + private Time clusterManagerTimeout; private String indexUuid; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - @Nullable private Time timeout; @@ -157,16 +161,39 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder * API name: {@code accept_data_loss} + *

*/ public final Builder acceptDataLoss(boolean value) { this.acceptDataLoss = value; return this; } + /** + * 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()); + } + /** * Required - The UUID of the dangling index *

* API name: {@code index_uuid} + *

*/ public final Builder indexUuid(String value) { this.indexUuid = value; @@ -177,6 +204,7 @@ public final Builder indexUuid(String value) { * Specify timeout for connection to master *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(@Nullable Time value) { @@ -188,35 +216,18 @@ public final Builder masterTimeout(@Nullable Time value) { * Specify timeout for connection to master *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; - return this; - } - - /** - * Specify timeout for connection to cluster-manager - *

- * 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()); } /** * Explicit operation timeout *

* API name: {@code timeout} + *

*/ public final Builder timeout(@Nullable Time value) { this.timeout = value; @@ -227,16 +238,16 @@ public final Builder timeout(@Nullable Time value) { * Explicit operation timeout *

* API name: {@code timeout} + *

*/ public final Builder timeout(Function> fn) { - return this.timeout(fn.apply(new Time.Builder()).build()); + return timeout(fn.apply(new Time.Builder()).build()); } /** * Builds a {@link ImportDanglingIndexRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public ImportDanglingIndexRequest build() { _checkSingleUse(); @@ -251,47 +262,29 @@ public ImportDanglingIndexRequest build() { * Endpoint "{@code dangling_indices.import_dangling_index}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "POST"; - - }, - + request -> "POST", // Request path request -> { - final int _indexUuid = 1 << 0; - - int propsSet = 0; - - propsSet |= _indexUuid; - - if (propsSet == (_indexUuid)) { - StringBuilder buf = new StringBuilder(); - buf.append("/_dangling"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.indexUuid, buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_dangling/"); + SimpleEndpoint.pathEncode(request.indexUuid, buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); - } + params.put("accept_data_loss", String.valueOf(request.acceptDataLoss)); if (request.clusterManagerTimeout != null) { params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); } - params.put("accept_data_loss", String.valueOf(request.acceptDataLoss)); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } return params; - }, SimpleEndpoint.emptyMap(), false, diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java similarity index 86% rename from java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java index 413913a404..90b180798e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java @@ -30,9 +30,14 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.dangling_indices; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; @@ -43,15 +48,18 @@ // typedef: dangling_indices.import_dangling_index.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class ImportDanglingIndexResponse extends AcknowledgedResponseBase { + // --------------------------------------------------------------------------------------------- private ImportDanglingIndexResponse(Builder builder) { super(builder); - } - public static ImportDanglingIndexResponse of(Function> fn) { + public static ImportDanglingIndexResponse of( + Function> fn + ) { return fn.apply(new Builder()).build(); } @@ -60,7 +68,6 @@ public static ImportDanglingIndexResponse of(Function implements ObjectBuilder { @@ -72,8 +79,7 @@ protected Builder self() { /** * Builds a {@link ImportDanglingIndexResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public ImportDanglingIndexResponse build() { _checkSingleUse(); @@ -81,7 +87,6 @@ public ImportDanglingIndexResponse build() { return new ImportDanglingIndexResponse(this); } } - // --------------------------------------------------------------------------------------------- /** @@ -94,7 +99,5 @@ public ImportDanglingIndexResponse build() { protected static void setupImportDanglingIndexResponseDeserializer(ObjectDeserializer op) { AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); - } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesRequest.java similarity index 86% rename from java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesRequest.java index 5e7f0b48c2..641bb9b012 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesRequest.java @@ -30,9 +30,13 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.dangling_indices; -import java.util.Collections; +import javax.annotation.Generated; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; import org.opensearch.client.transport.Endpoint; @@ -42,9 +46,8 @@ /** * Returns all dangling indices. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class ListDanglingIndicesRequest extends RequestBase { public ListDanglingIndicesRequest() {} @@ -59,24 +62,12 @@ public ListDanglingIndicesRequest() {} * Endpoint "{@code dangling_indices.list_dangling_indices}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // Request path - request -> { - return "/_dangling"; - - }, - + request -> "/_dangling", // Request parameters - request -> { - return Collections.emptyMap(); - - }, + SimpleEndpoint.emptyMap(), SimpleEndpoint.emptyMap(), false, ListDanglingIndicesResponse._DESERIALIZER diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java similarity index 67% rename from java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java index 31d1171432..1c26867fa5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java @@ -30,17 +30,24 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.dangling_indices; import jakarta.json.stream.JsonGenerator; import java.util.List; 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; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.NodeStatistics; import org.opensearch.client.opensearch.dangling_indices.list_dangling_indices.DanglingIndex; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; @@ -49,21 +56,39 @@ // typedef: dangling_indices.list_dangling_indices.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class ListDanglingIndicesResponse implements PlainJsonSerializable { + + @Nullable + private final String clusterName; + private final List danglingIndices; + @Nullable + private final NodeStatistics nodes; + // --------------------------------------------------------------------------------------------- private ListDanglingIndicesResponse(Builder builder) { - + this.clusterName = builder.clusterName; this.danglingIndices = ApiTypeHelper.unmodifiableRequired(builder.danglingIndices, this, "danglingIndices"); - + this.nodes = builder.nodes; } - public static ListDanglingIndicesResponse of(Function> fn) { + public static ListDanglingIndicesResponse of( + Function> fn + ) { return fn.apply(new Builder()).build(); } + /** + * API name: {@code cluster_name} + */ + @Nullable + public final String clusterName() { + return this.clusterName; + } + /** * Required - API name: {@code dangling_indices} */ @@ -71,9 +96,18 @@ public final List danglingIndices() { return this.danglingIndices; } + /** + * API name: {@code _nodes} + */ + @Nullable + public final NodeStatistics nodes() { + return this.nodes; + } + /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -81,15 +115,23 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.clusterName != null) { + generator.writeKey("cluster_name"); + generator.write(this.clusterName); + + } - if (ApiTypeHelper.isDefined(this.danglingIndices)) { - generator.writeKey("dangling_indices"); - generator.writeStartArray(); - for (DanglingIndex item0 : this.danglingIndices) { - item0.serialize(generator, mapper); + generator.writeKey("dangling_indices"); + generator.writeStartArray(); + for (DanglingIndex item0 : this.danglingIndices) { + item0.serialize(generator, mapper); - } - generator.writeEnd(); + } + generator.writeEnd(); + + if (this.nodes != null) { + generator.writeKey("_nodes"); + this.nodes.serialize(generator, mapper); } @@ -100,14 +142,27 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link ListDanglingIndicesResponse}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private String clusterName; private List danglingIndices; + @Nullable + private NodeStatistics nodes; + + /** + * API name: {@code cluster_name} + */ + public final Builder clusterName(@Nullable String value) { + this.clusterName = value; + return this; + } /** * Required - API name: {@code dangling_indices} + * *

* Adds all elements of list to danglingIndices. + *

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

* Adds one or more values to danglingIndices. + *

*/ public final Builder danglingIndices(DanglingIndex value, DanglingIndex... values) { this.danglingIndices = _listAdd(this.danglingIndices, value, values); @@ -126,18 +183,34 @@ public final Builder danglingIndices(DanglingIndex value, DanglingIndex... value /** * Required - API name: {@code dangling_indices} + * *

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

*/ public final Builder danglingIndices(Function> fn) { return danglingIndices(fn.apply(new DanglingIndex.Builder()).build()); } + /** + * API name: {@code _nodes} + */ + public final Builder nodes(@Nullable NodeStatistics value) { + this.nodes = value; + return this; + } + + /** + * API name: {@code _nodes} + */ + public final Builder nodes(Function> fn) { + return nodes(fn.apply(new NodeStatistics.Builder()).build()); + } + /** * Builds a {@link ListDanglingIndicesResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public ListDanglingIndicesResponse build() { _checkSingleUse(); @@ -145,7 +218,6 @@ public ListDanglingIndicesResponse build() { return new ListDanglingIndicesResponse(this); } } - // --------------------------------------------------------------------------------------------- /** @@ -157,9 +229,8 @@ public ListDanglingIndicesResponse build() { ); protected static void setupListDanglingIndicesResponseDeserializer(ObjectDeserializer op) { - + op.add(Builder::clusterName, JsonpDeserializer.stringDeserializer(), "cluster_name"); op.add(Builder::danglingIndices, JsonpDeserializer.arrayDeserializer(DanglingIndex._DESERIALIZER), "dangling_indices"); - + op.add(Builder::nodes, NodeStatistics._DESERIALIZER, "_nodes"); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java similarity index 88% rename from java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java index 402839470c..dc7158198f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java @@ -30,11 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.dangling_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.ErrorResponse; @@ -47,8 +52,8 @@ /** * Client for the dangling_indices namespace. */ +@Generated("org.opensearch.client.codegen.CodeGenerator") public class OpenSearchDanglingIndicesAsyncClient extends ApiClient { - public OpenSearchDanglingIndicesAsyncClient(OpenSearchTransport transport) { super(transport, null); } @@ -65,10 +70,8 @@ public OpenSearchDanglingIndicesAsyncClient withTransportOptions(@Nullable Trans // ----- Endpoint: dangling_indices.delete_dangling_index /** - * Deletes the specified dangling index - * + * Deletes the specified dangling index. */ - public CompletableFuture deleteDanglingIndex(DeleteDanglingIndexRequest request) throws IOException, OpenSearchException { @SuppressWarnings("unchecked") @@ -81,14 +84,10 @@ public CompletableFuture deleteDanglingIndex(Delete } /** - * Deletes the specified dangling index - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteDanglingIndexRequest} + * Deletes the specified dangling index. * + * @param fn a function that initializes a builder to create the {@link DeleteDanglingIndexRequest} */ - public final CompletableFuture deleteDanglingIndex( Function> fn ) throws IOException, OpenSearchException { @@ -98,11 +97,8 @@ public final CompletableFuture deleteDanglingIndex( // ----- Endpoint: dangling_indices.import_dangling_index /** - * Imports the specified dangling index - * - * + * Imports the specified dangling index. */ - public CompletableFuture importDanglingIndex(ImportDanglingIndexRequest request) throws IOException, OpenSearchException { @SuppressWarnings("unchecked") @@ -115,14 +111,10 @@ public CompletableFuture importDanglingIndex(Import } /** - * Imports the specified dangling index - * - * @param fn - * a function that initializes a builder to create the - * {@link ImportDanglingIndexRequest} + * Imports the specified dangling index. * + * @param fn a function that initializes a builder to create the {@link ImportDanglingIndexRequest} */ - public final CompletableFuture importDanglingIndex( Function> fn ) throws IOException, OpenSearchException { @@ -133,8 +125,6 @@ public final CompletableFuture importDanglingIndex( /** * Returns all dangling indices. - * - * */ public CompletableFuture listDanglingIndices() throws IOException, OpenSearchException { return this.transport.performRequestAsync( @@ -143,5 +133,4 @@ public CompletableFuture listDanglingIndices() thro this.transportOptions ); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java similarity index 87% rename from java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java index 5c9e4985db..c4ebd9da0e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.dangling_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.ErrorResponse; @@ -46,8 +51,8 @@ /** * Client for the dangling_indices namespace. */ +@Generated("org.opensearch.client.codegen.CodeGenerator") public class OpenSearchDanglingIndicesClient extends ApiClient { - public OpenSearchDanglingIndicesClient(OpenSearchTransport transport) { super(transport, null); } @@ -64,11 +69,8 @@ public OpenSearchDanglingIndicesClient withTransportOptions(@Nullable TransportO // ----- Endpoint: dangling_indices.delete_dangling_index /** - * Deletes the specified dangling index - * - * + * Deletes the specified dangling index. */ - public DeleteDanglingIndexResponse deleteDanglingIndex(DeleteDanglingIndexRequest request) throws IOException, OpenSearchException { @SuppressWarnings("unchecked") JsonEndpoint endpoint = (JsonEndpoint< @@ -80,14 +82,10 @@ public DeleteDanglingIndexResponse deleteDanglingIndex(DeleteDanglingIndexReques } /** - * Deletes the specified dangling index - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteDanglingIndexRequest} + * Deletes the specified dangling index. * + * @param fn a function that initializes a builder to create the {@link DeleteDanglingIndexRequest} */ - public final DeleteDanglingIndexResponse deleteDanglingIndex( Function> fn ) throws IOException, OpenSearchException { @@ -97,11 +95,8 @@ public final DeleteDanglingIndexResponse deleteDanglingIndex( // ----- Endpoint: dangling_indices.import_dangling_index /** - * Imports the specified dangling index - * - * + * Imports the specified dangling index. */ - public ImportDanglingIndexResponse importDanglingIndex(ImportDanglingIndexRequest request) throws IOException, OpenSearchException { @SuppressWarnings("unchecked") JsonEndpoint endpoint = (JsonEndpoint< @@ -113,14 +108,10 @@ public ImportDanglingIndexResponse importDanglingIndex(ImportDanglingIndexReques } /** - * Imports the specified dangling index - * - * @param fn - * a function that initializes a builder to create the - * {@link ImportDanglingIndexRequest} + * Imports the specified dangling index. * + * @param fn a function that initializes a builder to create the {@link ImportDanglingIndexRequest} */ - public final ImportDanglingIndexResponse importDanglingIndex( Function> fn ) throws IOException, OpenSearchException { @@ -131,8 +122,6 @@ public final ImportDanglingIndexResponse importDanglingIndex( /** * Returns all dangling indices. - * - * */ public ListDanglingIndicesResponse listDanglingIndices() throws IOException, OpenSearchException { return this.transport.performRequest( @@ -141,5 +130,4 @@ public ListDanglingIndicesResponse listDanglingIndices() throws IOException, Ope this.transportOptions ); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java similarity index 78% rename from java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java index b893eb9946..822758ab0f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java @@ -30,11 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.dangling_indices.list_dangling_indices; import jakarta.json.stream.JsonGenerator; import java.util.List; 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; import org.opensearch.client.json.JsonpMapper; @@ -48,30 +54,49 @@ // typedef: dangling_indices.list_dangling_indices.DanglingIndex @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class DanglingIndex implements PlainJsonSerializable { + + @Nullable + private final String creationDate; + + private final long creationDateMillis; + private final String indexName; private final String indexUuid; - private final String creationDateMillis; - private final List nodeIds; // --------------------------------------------------------------------------------------------- private DanglingIndex(Builder builder) { - + this.creationDate = builder.creationDate; + this.creationDateMillis = ApiTypeHelper.requireNonNull(builder.creationDateMillis, this, "creationDateMillis"); this.indexName = ApiTypeHelper.requireNonNull(builder.indexName, this, "indexName"); this.indexUuid = ApiTypeHelper.requireNonNull(builder.indexUuid, this, "indexUuid"); - this.creationDateMillis = ApiTypeHelper.requireNonNull(builder.creationDateMillis, this, "creationDateMillis"); this.nodeIds = ApiTypeHelper.unmodifiableRequired(builder.nodeIds, this, "nodeIds"); - } - public static DanglingIndex of(Function> fn) { + public static DanglingIndex of(Function> fn) { return fn.apply(new Builder()).build(); } + /** + * API name: {@code creation_date} + */ + @Nullable + public final String creationDate() { + return this.creationDate; + } + + /** + * Required - API name: {@code creation_date_millis} + */ + public final long creationDateMillis() { + return this.creationDateMillis; + } + /** * Required - API name: {@code index_name} */ @@ -86,13 +111,6 @@ public final String indexUuid() { return this.indexUuid; } - /** - * Required - API name: {@code creation_date_millis} - */ - public final String creationDateMillis() { - return this.creationDateMillis; - } - /** * Required - API name: {@code node_ids} */ @@ -103,6 +121,7 @@ public final List nodeIds() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -110,6 +129,14 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.creationDate != null) { + generator.writeKey("creation_date"); + generator.write(this.creationDate); + + } + + generator.writeKey("creation_date_millis"); + generator.write(this.creationDateMillis); generator.writeKey("index_name"); generator.write(this.indexName); @@ -117,19 +144,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("index_uuid"); generator.write(this.indexUuid); - generator.writeKey("creation_date_millis"); - generator.write(this.creationDateMillis); - - if (ApiTypeHelper.isDefined(this.nodeIds)) { - generator.writeKey("node_ids"); - generator.writeStartArray(); - for (String item0 : this.nodeIds) { - generator.write(item0); - - } - generator.writeEnd(); + generator.writeKey("node_ids"); + generator.writeStartArray(); + for (String item0 : this.nodeIds) { + generator.write(item0); } + generator.writeEnd(); } @@ -138,15 +159,29 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link DanglingIndex}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private String creationDate; + private Long creationDateMillis; private String indexName; - private String indexUuid; + private List nodeIds; - private String creationDateMillis; + /** + * API name: {@code creation_date} + */ + public final Builder creationDate(@Nullable String value) { + this.creationDate = value; + return this; + } - private List nodeIds; + /** + * Required - API name: {@code creation_date_millis} + */ + public final Builder creationDateMillis(long value) { + this.creationDateMillis = value; + return this; + } /** * Required - API name: {@code index_name} @@ -164,18 +199,12 @@ public final Builder indexUuid(String value) { return this; } - /** - * Required - API name: {@code creation_date_millis} - */ - public final Builder creationDateMillis(String value) { - this.creationDateMillis = value; - return this; - } - /** * Required - API name: {@code node_ids} + * *

* Adds all elements of list to nodeIds. + *

*/ public final Builder nodeIds(List list) { this.nodeIds = _listAddAll(this.nodeIds, list); @@ -184,8 +213,10 @@ public final Builder nodeIds(List list) { /** * Required - API name: {@code node_ids} + * *

* Adds one or more values to nodeIds. + *

*/ public final Builder nodeIds(String value, String... values) { this.nodeIds = _listAdd(this.nodeIds, value, values); @@ -195,8 +226,7 @@ public final Builder nodeIds(String value, String... values) { /** * Builds a {@link DanglingIndex}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public DanglingIndex build() { _checkSingleUse(); @@ -204,7 +234,6 @@ public DanglingIndex build() { return new DanglingIndex(this); } } - // --------------------------------------------------------------------------------------------- /** @@ -216,12 +245,10 @@ public DanglingIndex build() { ); protected static void setupDanglingIndexDeserializer(ObjectDeserializer op) { - + op.add(Builder::creationDate, JsonpDeserializer.stringDeserializer(), "creation_date"); + op.add(Builder::creationDateMillis, JsonpDeserializer.longDeserializer(), "creation_date_millis"); op.add(Builder::indexName, JsonpDeserializer.stringDeserializer(), "index_name"); op.add(Builder::indexUuid, JsonpDeserializer.stringDeserializer(), "index_uuid"); - op.add(Builder::creationDateMillis, JsonpDeserializer.stringDeserializer(), "creation_date_millis"); op.add(Builder::nodeIds, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "node_ids"); - } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java index 8250942fd3..3326baa189 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java @@ -120,7 +120,6 @@ import org.opensearch.client.opensearch.core.pit.DeletePitResponse; import org.opensearch.client.opensearch.core.pit.ListAllPitRequest; import org.opensearch.client.opensearch.core.pit.ListAllPitResponse; -import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesAsyncClient; import org.opensearch.client.opensearch.features.OpenSearchFeaturesAsyncClient; import org.opensearch.client.opensearch.indices.OpenSearchIndicesAsyncClient; import org.opensearch.client.opensearch.ingest.OpenSearchIngestAsyncClient; @@ -154,10 +153,6 @@ public OpenSearchClusterAsyncClient cluster() { return new OpenSearchClusterAsyncClient(this.transport, this.transportOptions); } - public OpenSearchDanglingIndicesAsyncClient danglingIndices() { - return new OpenSearchDanglingIndicesAsyncClient(this.transport, this.transportOptions); - } - public OpenSearchFeaturesAsyncClient features() { return new OpenSearchFeaturesAsyncClient(this.transport, this.transportOptions); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClientBase.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClientBase.java index d4b2d661cd..3c361c66fc 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClientBase.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClientBase.java @@ -119,7 +119,6 @@ import org.opensearch.client.opensearch.core.pit.DeletePitResponse; import org.opensearch.client.opensearch.core.pit.ListAllPitRequest; import org.opensearch.client.opensearch.core.pit.ListAllPitResponse; -import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesClient; import org.opensearch.client.opensearch.features.OpenSearchFeaturesClient; import org.opensearch.client.opensearch.generic.OpenSearchGenericClient; import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient; @@ -157,10 +156,6 @@ public OpenSearchClusterClient cluster() { return new OpenSearchClusterClient(this.transport, this.transportOptions); } - public OpenSearchDanglingIndicesClient danglingIndices() { - return new OpenSearchDanglingIndicesClient(this.transport, this.transportOptions); - } - public OpenSearchFeaturesClient features() { return new OpenSearchFeaturesClient(this.transport, this.transportOptions); } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/json/PlainJsonSerializableTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/json/PlainJsonSerializableTest.java index 2f504c48fc..c0af29e51b 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/json/PlainJsonSerializableTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/json/PlainJsonSerializableTest.java @@ -23,7 +23,7 @@ public class PlainJsonSerializableTest extends Assert { public void testIndexResponse() { String expectedStringValue = - "{\"_id\":\"id\",\"_index\":\"index\",\"_primary_term\":1,\"result\":\"created\",\"_seq_no\":2,\"_shards\":{\"failed\":1.0,\"successful\":1.0,\"total\":3.0,\"failures\":[{\"index\":\"index\",\"node\":\"node\",\"reason\":{\"type\":\"query_shard_exception\",\"reason\":\"Failed to create query.\"},\"shard\":1,\"status\":\"Failed\"}],\"skipped\":1.0},\"_version\":3}"; + "{\"_id\":\"id\",\"_index\":\"index\",\"_primary_term\":1,\"result\":\"created\",\"_seq_no\":2,\"_shards\":{\"failed\":1.0,\"successful\":1.0,\"total\":3.0,\"failures\":[{\"index\":\"index\",\"node\":\"node\",\"reason\":{\"reason\":\"Failed to create query.\",\"type\":\"query_shard_exception\"},\"shard\":1,\"status\":\"Failed\"}],\"skipped\":1.0},\"_version\":3}"; IndexResponse indexResponse = IndexResponse.of( response -> response.result(Result.Created) .index("index") diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/model/BehaviorsTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/model/BehaviorsTest.java index cd10c73915..d79f2156af 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/model/BehaviorsTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/model/BehaviorsTest.java @@ -147,7 +147,7 @@ public void testAdditionalProperties() { .metadata(MapBuilder.of("index", JsonData.of("test"), "retries", JsonData.of(1))) .build(); - err = checkJsonRoundtrip(err, "{\"index\":\"test\",\"retries\":1,\"type\":\"Some type\",\"reason\":\"Some failure\"}"); + err = checkJsonRoundtrip(err, "{\"index\":\"test\",\"retries\":1,\"reason\":\"Some failure\",\"type\":\"Some type\"}"); assertEquals("Some failure", err.reason()); assertEquals(1, err.metadata().get("retries").to(int.class).intValue()); diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index 43c7dd003c..fb5695388c 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -64,7 +64,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' - $ref: '#/components/parameters/indices.put_alias::query.master_timeout' @@ -128,7 +128,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.name' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -150,7 +150,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.name' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -173,7 +173,7 @@ paths: x-version-added: '1.0' description: Updates index aliases. externalDocs: - url: https://opensearch.org/docs/latest/api-reference/alias/ + url: https://opensearch.org/docs/latest/api-reference/index-apis/alias/ parameters: - $ref: '#/components/parameters/indices.update_aliases::query.cluster_manager_timeout' - $ref: '#/components/parameters/indices.update_aliases::query.master_timeout' @@ -195,7 +195,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.name' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -217,7 +217,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.name' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -5626,6 +5626,108 @@ paths: - $ref: '#/components/parameters/_global::query.error_trace' - $ref: '#/components/parameters/_global::query.source' - $ref: '#/components/parameters/_global::query.filter_path' + /_plugins/_sql: + post: + operationId: sql.query.0 + x-operation-group: sql.query + x-version-added: '1.0' + description: Send a SQL/PPL query to the SQL plugin. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.query::query.format' + - $ref: '#/components/parameters/sql.query::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/sql.query' + responses: + '200': + $ref: '#/components/responses/sql.query@200' + /_plugins/_sql/_explain: + post: + operationId: sql.explain.0 + x-operation-group: sql.explain + x-version-added: '1.0' + description: Shows how a query is executed against OpenSearch. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.explain::query.format' + - $ref: '#/components/parameters/sql.explain::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/sql.explain' + responses: + '200': + $ref: '#/components/responses/sql.explain@200' + /_plugins/_sql/close: + post: + operationId: sql.close.0 + x-operation-group: sql.close + x-version-added: '1.0' + description: Clear the cursor context. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.close::query.format' + - $ref: '#/components/parameters/sql.close::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/sql.close' + responses: + '200': + $ref: '#/components/responses/sql.close@200' + /_plugins/_sql/stats: + get: + operationId: sql.get_stats.0 + x-operation-group: sql.get_stats + x-version-added: '1.0' + description: Collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.get_stats::query.format' + - $ref: '#/components/parameters/sql.get_stats::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/sql.get_stats@200' + post: + operationId: sql.post_stats.1 + x-operation-group: sql.post_stats + x-version-added: '1.0' + description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.post_stats::query.format' + - $ref: '#/components/parameters/sql.post_stats::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/sql.post_stats' + responses: + '200': + $ref: '#/components/responses/sql.post_stats@200' /_plugins/_transform: get: operationId: transforms.search.0 @@ -7796,7 +7898,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -7884,7 +7986,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::path.name' @@ -7907,7 +8009,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::path.name' @@ -7931,7 +8033,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -7975,7 +8077,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::path.name' @@ -7998,7 +8100,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::path.name' @@ -11603,6 +11705,118 @@ paths: - $ref: '#/components/parameters/_global::query.filter_path' deprecated: true x-ignorable: true + /_opendistro/_sql: + post: + operationId: sql.query.0_superseded + x-operation-group: sql.query + x-version-added: '1.0' + description: Send a SQL/PPL query to the SQL plugin. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.query::query.format' + - $ref: '#/components/parameters/sql.query::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/sql.query' + responses: + '200': + $ref: '#/components/responses/sql.query@200' + deprecated: true + x-ignorable: true + /_opendistro/_sql/_explain: + post: + operationId: sql.explain.0_superseded + x-operation-group: sql.explain + x-version-added: '1.0' + description: Shows how a query is executed against OpenSearch. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.explain::query.format' + - $ref: '#/components/parameters/sql.explain::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/sql.explain' + responses: + '200': + $ref: '#/components/responses/sql.explain@200' + deprecated: true + x-ignorable: true + /_opendistro/_sql/close: + post: + operationId: sql.close.0_superseded + x-operation-group: sql.close + x-version-added: '1.0' + description: Clear the cursor context. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.close::query.format' + - $ref: '#/components/parameters/sql.close::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/sql.close' + responses: + '200': + $ref: '#/components/responses/sql.close@200' + deprecated: true + x-ignorable: true + /_opendistro/_sql/stats: + get: + operationId: sql.get_stats.0_superseded + x-operation-group: sql.get_stats + x-version-added: '1.0' + description: Collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.get_stats::query.format' + - $ref: '#/components/parameters/sql.get_stats::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/sql.get_stats@200' + deprecated: true + x-ignorable: true + post: + operationId: sql.post_stats.1_superseded + x-operation-group: sql.post_stats + x-version-added: '1.0' + description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.post_stats::query.format' + - $ref: '#/components/parameters/sql.post_stats::query.sanitize' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/sql.post_stats' + responses: + '200': + $ref: '#/components/responses/sql.post_stats@200' + deprecated: true + x-ignorable: true components: parameters: _global::query.pretty: @@ -21070,6 +21284,81 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form + sql.close::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.close::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.explain::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.explain::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.get_stats::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.get_stats::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.post_stats::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.post_stats::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.query::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.query::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results tasks.cancel::path.task_id: in: path name: task_id @@ -22521,18 +22810,7 @@ components: ml.search_models: content: application/json: - schema: - type: object - properties: - query: - type: object - description: The query. - size: - type: integer - description: The number of models to return. - required: - - query - - size + $ref: '#/components/schemas/ml._common:SearchModelsQuery' msearch: content: application/x-ndjson: @@ -23212,6 +23490,30 @@ components: rename_replacement: type: string description: Details of what to restore + sql.close: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlClose' + required: true + sql.explain: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlExplain' + required: true + sql.post_stats: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlStats' + required: true + sql.query: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlQuery' + required: true termvectors: content: application/json: @@ -24699,106 +25001,31 @@ components: ml.delete_model_group@200: content: application/json: - schema: - type: object + $ref: '#/components/schemas/ml._common:ModelGroup' ml.delete_model@200: content: application/json: - schema: - type: object + $ref: '#/components/schemas/ml._common:ModelGroup' ml.get_model_group@200: content: application/json: - schema: - type: object - properties: - name: - type: string - description: The model group name. - latest_version: - type: number - description: The latest version. - description: - type: string - description: The model group description. - access: - type: string - description: The model group access. - created_time: - type: integer - format: int64 - last_updated_time: - type: integer - format: int64 - required: - - access - - description - - latest_version - - name + $ref: '#/components/schemas/ml._common:ModelGroup' ml.get_task@200: content: application/json: - schema: - type: object - properties: - model_id: - type: string - description: The model ID. - state: - type: string - description: The state. - enum: - - CANCELLED - - COMPLETED - - COMPLETED_WITH_ERROR - - CREATED - - FAILED - - RUNNING - required: - - state + $ref: '#/components/schemas/ml._common:Task' ml.register_model_group@200: content: application/json: - schema: - type: object - properties: - model_group_id: - type: string - description: The model group ID. - status: - type: string - description: The status. - required: - - model_group_id - - status + $ref: '#/components/schemas/ml._common:ModelGroupRegistration' ml.register_model@200: content: application/json: - schema: - type: object - properties: - task_id: - type: string - description: The task ID. - model_id: - type: string - description: The model ID. - status: - type: string - description: The status. - required: - - status - - task_id + $ref: '#/components/schemas/ml._common:Task' ml.search_models@200: content: application/json: - schema: - type: object - properties: - hits: - $ref: '#/components/schemas/ml._common:SearchModelHits' - required: - - hits + $ref: '#/components/schemas/ml._common:SearchModelsResponse' msearch_template@200: description: '' content: @@ -25965,6 +26192,36 @@ components: $ref: '#/components/schemas/snapshot.verify_repository:CompactNodeInfo' required: - nodes + sql.close@200: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlCloseResponse' + required: true + sql.explain@200: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlExplainResponse' + required: true + sql.get_stats@200: + content: + text/plain: + schema: + type: string + required: true + sql.post_stats@200: + content: + text/plain: + schema: + type: string + required: true + sql.query@200: + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlQueryResponse' tasks.cancel@200: description: '' content: @@ -26449,6 +26706,9 @@ components: $ref: '#/components/schemas/_common:ErrorCause' required: - type + additionalProperties: + title: metadata + description: Additional details about the error _common:ErrorResponseBase: type: object properties: @@ -27531,8 +27791,7 @@ components: Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time. type: object - additionalProperties: - type: object + additionalProperties: true _common:ScriptField: type: object properties: @@ -28097,6 +28356,7 @@ components: _common:UnitMillis: description: Time unit for milliseconds type: number + format: int64 _common:UnitNanos: description: Time unit for nanoseconds type: number @@ -33841,8 +34101,8 @@ components: type: string enum: - 'false' - - runtime - strict + - strict_allow_templates - 'true' _common.mapping:DynamicProperty: allOf: @@ -36106,7 +36366,9 @@ components: To return a document, the query term must exactly match the queried field's value, including whitespace and capitalization. type: object additionalProperties: - $ref: '#/components/schemas/_common.query_dsl:TermQuery' + anyOf: + - $ref: '#/components/schemas/_common.query_dsl:TermQuery' + - $ref: '#/components/schemas/_common:FieldValue' minProperties: 1 maxProperties: 1 terms: @@ -41704,6 +41966,8 @@ components: type: string index_uuid: type: string + creation_date: + $ref: '#/components/schemas/_common:DateTime' creation_date_millis: $ref: '#/components/schemas/_common:EpochTimeUnitMillis' node_ids: @@ -44738,7 +45002,45 @@ components: required: - relation - value - ml._common:SearchModelHits: + ml._common:ModelGroup: + type: object + properties: + name: + type: string + description: The model group name. + latest_version: + type: number + description: The latest version. + description: + type: string + description: The model group description. + access: + type: string + description: The model group access. + created_time: + type: integer + format: int64 + last_updated_time: + type: integer + format: int64 + required: + - access + - description + - latest_version + - name + ml._common:ModelGroupRegistration: + type: object + properties: + model_group_id: + type: string + description: The model group ID. + status: + type: string + description: The status. + required: + - model_group_id + - status + ml._common:SearchModelsHits: type: object properties: total: @@ -44746,11 +45048,11 @@ components: hits: type: array items: - $ref: '#/components/schemas/ml._common:SearchModelHitsHit' + $ref: '#/components/schemas/ml._common:SearchModelsHitsHit' required: - hits - total - ml._common:SearchModelHitsHit: + ml._common:SearchModelsHitsHit: type: object properties: _index: @@ -44765,6 +45067,62 @@ components: required: - _id - model_id + ml._common:SearchModelsQuery: + type: object + properties: + query: + type: object + description: The query. + size: + type: integer + description: The number of models to return. + required: + - query + - size + ml._common:SearchModelsResponse: + type: object + properties: + hits: + $ref: '#/components/schemas/ml._common:SearchModelsHits' + required: + - hits + ml._common:Task: + type: object + properties: + model_id: + type: string + description: The model ID. + state: + type: string + description: The state. + enum: + - CANCELLED + - COMPLETED + - COMPLETED_WITH_ERROR + - CREATED + - FAILED + - RUNNING + task_type: + type: string + description: Task type. + enum: + - DEPLOY_MODEL + function_name: + type: string + worker_node: + type: array + items: + $ref: '#/components/schemas/_common:NodeIds' + create_time: + type: integer + format: int64 + last_update_time: + type: integer + format: int64 + is_async: + type: boolean + required: + - state nodes._common:AdaptiveSelection: type: object properties: @@ -48503,6 +48861,86 @@ components: $ref: '#/components/schemas/_common:Name' required: - name + sql._common:Explain: + type: object + properties: + name: + type: string + description: + type: object + children: + type: array + items: + $ref: '#/components/schemas/sql._common:Explain' + sql._common:SqlClose: + type: object + properties: + cursor: + type: string + sql._common:SqlCloseResponse: + type: object + properties: + succeeded: + type: boolean + sql._common:SqlExplain: + type: object + properties: + query: + type: string + filter: + type: object + fetch_size: + type: integer + sql._common:SqlExplainResponse: + type: object + properties: + root: + $ref: '#/components/schemas/sql._common:Explain' + sql._common:SqlQuery: + type: object + properties: + query: + type: string + filter: + type: object + fetch_size: + type: integer + sql._common:SqlQueryResponse: + type: object + properties: + schema: + type: array + items: + type: object + datarows: + type: array + items: + type: array + cursor: + type: string + total: + type: integer + size: + type: integer + status: + type: integer + sql._common:SqlStats: + type: object + properties: + start_time: + type: string + end_time: + type: object + cluster_name: + type: object + index: + type: object + query: + type: object + user: + type: object + execution_time: + type: object tasks._common:GroupBy: type: string enum: 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 16db1f6d3e..457bc38f80 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 @@ -33,7 +33,7 @@ public class CodeGenerator { private static final Logger LOGGER = LogManager.getLogger(); - private static final OperationGroup.Matcher OPERATION_MATCHER = OperationGroup.matcher().add(null, "info"); + private static final OperationGroup.Matcher OPERATION_MATCHER = OperationGroup.matcher().add(null, "info").add("dangling_indices"); public static void main(String[] args) { var inputOpt = Option.builder("i") diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java index 97540564eb..d04f66f6f7 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java @@ -31,7 +31,7 @@ public Collection getAnnotations() { @Override public Collection getImplementsTypes() { - return List.of(Types.Client.Json.JsonpSerializable); + return List.of(Types.Client.Json.PlainJsonSerializable); } public Field getValueBodyField() { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java index f2a95028d4..e4d1734572 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java @@ -24,6 +24,7 @@ public class Field { private final String description; @Nullable private final Deprecation deprecation; + private final boolean isAdditionalProperties; public Field( @Nonnull String wireName, @@ -31,12 +32,24 @@ public Field( boolean required, @Nullable String description, @Nullable Deprecation deprecation + ) { + this(wireName, type, required, description, deprecation, false); + } + + public Field( + @Nonnull String wireName, + @Nonnull Type type, + boolean required, + @Nullable String description, + @Nullable Deprecation deprecation, + boolean isAdditionalProperties ) { this.wireName = Strings.requireNonBlank(wireName, "wireName must not be null"); this.type = Objects.requireNonNull(type, "type must not be null"); this.required = required; this.description = description; this.deprecation = deprecation; + this.isAdditionalProperties = isAdditionalProperties; } @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPath.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPath.java index 8050fc21e6..36573e6e5e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPath.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPath.java @@ -64,8 +64,8 @@ public List getParams() { return Lists.filterMap(parts, Part::isParameter, Part::getParameter); } - public Set getParamNameSet() { - return parts.stream().filter(Part::isParameter).map(p -> p.getParameter().getName()).collect(Collectors.toSet()); + public Set getParamWireNameSet() { + return parts.stream().filter(Part::isParameter).map(p -> p.getParameter().getWireName()).collect(Collectors.toSet()); } public Deprecation getDeprecation() { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java index 3398b98583..1f455426a3 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java @@ -16,6 +16,7 @@ import java.util.TreeMap; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.opensearch.client.codegen.exceptions.RenderException; import org.opensearch.client.codegen.utils.Lists; import org.opensearch.client.codegen.utils.Strings; @@ -96,7 +97,7 @@ private String getClientClassName(boolean async, boolean base) { private Type getClientType(boolean async, boolean base) { var type = Type.builder().pkg(getPackageName()).name(getClientClassName(async, base)); if (base) { - type.genericArgs(getClientType(async, false)); + type.typeParams(getClientType(async, false)); } return type.build(); } @@ -106,7 +107,7 @@ private static class Client extends Shape { private final Collection operations; private Client(Namespace parent, boolean async, Collection operations) { - super(parent, parent.getClientClassName(async, false), null, null); + super(parent, parent.getClientClassName(async, false), null, "Client for the " + parent.name + " namespace."); this.async = async; this.operations = operations; } @@ -137,6 +138,11 @@ public boolean isAsync() { return this.async; } + @Override + public String toString() { + return new ToStringBuilder(this).append("type", getType()).toString(); + } + private static class ClientRef { private final Type type; private final String name; 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 3dcbd1127a..39bb2e2e86 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 @@ -56,11 +56,19 @@ public Type getExtendsType() { return extendsType; } + public boolean extendsOtherShape() { + return extendsType != null; + } + + public boolean hasFieldsToSerialize() { + return !bodyFields.isEmpty() || additionalPropertiesField != null; + } + public Collection getImplementsTypes() { - return !bodyFields.isEmpty() ? List.of(Types.Client.Json.JsonpSerializable) : null; + return hasFieldsToSerialize() && !extendsOtherShape() ? List.of(Types.Client.Json.PlainJsonSerializable) : null; } public Collection getAnnotations() { - return !bodyFields.isEmpty() ? List.of(Types.Client.Json.JsonpDeserializable) : null; + return (hasFieldsToSerialize() || extendsOtherShape()) && !isAbstract() ? List.of(Types.Client.Json.JsonpDeserializable) : null; } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index b46ef19025..a2625fc7ce 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -50,6 +50,11 @@ public String getId() { return operationGroup.getName(); } + @Override + public boolean extendsOtherShape() { + return extendsType != Types.Client.OpenSearch._Types.RequestBase; + } + public String getHttpMethod() { return Streams.sortedBy(httpMethods.stream(), m -> { switch (m) { @@ -144,6 +149,10 @@ public boolean hasAnyRequiredFields() { return fields.values().stream().anyMatch(Field::isRequired); } + public Type getJsonEndpointType() { + return Types.Client.Transport.JsonEndpoint(getType(), getResponseType(), Types.Client.OpenSearch._Types.ErrorResponse); + } + @Nonnull private static String requestClassName(@Nonnull OperationGroup operationGroup) { Objects.requireNonNull(operationGroup, "operationGroup must not be null"); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java index 9b24cac8d9..bd20d083c6 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java @@ -45,6 +45,10 @@ public JavaClassKind getClassKind() { return JavaClassKind.Class; } + public boolean isAbstract() { + return this.className.endsWith("Base"); + } + public String getTypedefName() { return this.typedefName; } 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 09f24a35e0..91af05c63f 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,11 +28,13 @@ import org.apache.logging.log4j.Logger; import org.opensearch.client.codegen.openapi.HttpStatusCode; import org.opensearch.client.codegen.openapi.In; +import org.opensearch.client.codegen.openapi.JsonPointer; import org.opensearch.client.codegen.openapi.MimeType; import org.opensearch.client.codegen.openapi.OpenApiMediaType; import org.opensearch.client.codegen.openapi.OpenApiOperation; import org.opensearch.client.codegen.openapi.OpenApiParameter; import org.opensearch.client.codegen.openapi.OpenApiPath; +import org.opensearch.client.codegen.openapi.OpenApiRefElement; import org.opensearch.client.codegen.openapi.OpenApiRequestBody; import org.opensearch.client.codegen.openapi.OpenApiResponse; import org.opensearch.client.codegen.openapi.OpenApiSchema; @@ -104,7 +106,16 @@ private void visit(@Nonnull OperationGroup group, @Nonnull List c.get(MimeType.Json)) .flatMap(OpenApiMediaType::getSchema) - .map(OpenApiSchema::resolve) + .map(s -> { + if (s.get$ref() + .map(OpenApiRefElement.RelativeRef::getPointer) + .flatMap(JsonPointer::getLastKey) + .map("_common:AcknowledgedResponseBase"::equals) + .orElse(false)) { + return OpenApiSchema.builder().withPointer(s.getPointer()).withAllOf(s, OpenApiSchema.ANONYMOUS_OBJECT).build(); + } + return s.resolve(); + }) .orElse(OpenApiSchema.ANONYMOUS_OBJECT); visit(parent, requestShape.getResponseType().getName(), group + ".Response", responseSchema); @@ -139,12 +150,12 @@ private RequestShape visit(@Nonnull Namespace parent, @Nonnull OperationGroup gr var httpPath = HttpPath.from(httpPathStr, variant, allPathParams); - (httpPath.getDeprecation() == null ? canonicalPaths : deprecatedPaths).put(httpPath.getParamNameSet(), httpPath); + (httpPath.getDeprecation() == null ? canonicalPaths : deprecatedPaths).put(httpPath.getParamWireNameSet(), httpPath); if (requiredPathParams != null) { - requiredPathParams.retainAll(httpPath.getParamNameSet()); + requiredPathParams.retainAll(httpPath.getParamWireNameSet()); } else { - requiredPathParams = new HashSet<>(httpPath.getParamNameSet()); + requiredPathParams = new HashSet<>(httpPath.getParamWireNameSet()); } } @@ -277,16 +288,17 @@ private void visitInto(OpenApiSchema schema, ObjectShape shape) { ) ); - var additionalProperties = schema.getAdditionalProperties(); - if (additionalProperties.isPresent()) { - var valueType = mapType(additionalProperties.get()); + var additionalProperties = schema.getAdditionalProperties().orElse(null); + if (additionalProperties != null) { + var valueType = mapType(additionalProperties); shape.setAdditionalPropertiesField( new Field( - "metadata", + additionalProperties.getTitle().orElseThrow(), Types.Java.Util.Map(Types.Java.Lang.String, valueType), false, - additionalProperties.get().getDescription().orElse(null), - null + additionalProperties.getDescription().orElse(null), + null, + true ) ); } 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 85e96761a0..36dc7e2f2a 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 @@ -41,7 +41,7 @@ public Collection getAnnotations() { public Collection getImplementsTypes() { return List.of( Types.Client.Util.TaggedUnion(getType().getNestedType("Kind"), Types.Java.Lang.Object), - Types.Client.Json.JsonpSerializable + Types.Client.Json.PlainJsonSerializable ); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java index 96ef37d344..ca4d27a0a3 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java @@ -45,26 +45,26 @@ public static Builder builder() { private final String pkg; private final String name; - private final Type[] genericArgs; + private final Type[] typeParams; private final boolean isEnum; private Type(Builder builder) { this.pkg = builder.pkg; this.name = builder.name; - this.genericArgs = builder.genericArgs; + this.typeParams = builder.typeParams; this.isEnum = builder.isEnum; } public Builder toBuilder() { - return new Builder().pkg(pkg).name(name).genericArgs(genericArgs).isEnum(isEnum); + return new Builder().pkg(pkg).name(name).typeParams(typeParams).isEnum(isEnum); } @Override public String toString() { String str = name; - if (genericArgs != null && genericArgs.length > 0) { + if (typeParams != null && typeParams.length > 0) { str += "<"; - str += Arrays.stream(genericArgs).map(Type::toString).collect(Collectors.joining(", ")); + str += Arrays.stream(typeParams).map(Type::toString).collect(Collectors.joining(", ")); str += ">"; } return str; @@ -104,19 +104,19 @@ public boolean isMap() { public Type getMapEntryType() { if (!isMap()) return null; - return Java.Util.MapEntry(this.genericArgs[0], this.genericArgs[1]); + return Java.Util.MapEntry(this.typeParams[0], this.typeParams[1]); } public Type getMapKeyType() { if (!isMap()) return null; - return this.genericArgs[0]; + return this.typeParams[0]; } public Type getMapValueType() { if (!isMap()) return null; - return this.genericArgs[1]; + return this.typeParams[1]; } public boolean isList() { @@ -126,7 +126,7 @@ public boolean isList() { public Type getListValueType() { if (!isList()) return null; - return this.genericArgs[0]; + return this.typeParams[0]; } public boolean isListOrMap() { @@ -186,15 +186,15 @@ public void getRequiredImports(Set imports, String currentPkg) { var dotIdx = name.indexOf('.'); imports.add(pkg + '.' + (dotIdx > 0 ? name.substring(0, dotIdx) : name)); } - if (genericArgs != null) { - for (Type arg : genericArgs) { + if (typeParams != null) { + for (Type arg : typeParams) { arg.getRequiredImports(imports, currentPkg); } } } - public Type withGenericArgs(Type... genericArgs) { - return toBuilder().genericArgs(genericArgs).build(); + public Type withTypeParams(Type... typeParams) { + return toBuilder().typeParams(typeParams).build(); } public Mustache.Lambda queryParamify() { @@ -204,7 +204,7 @@ public Mustache.Lambda queryParamify() { public static final class Builder { private String pkg; private String name; - private Type[] genericArgs; + private Type[] typeParams; private boolean isEnum; public Builder pkg(String pkg) { @@ -217,8 +217,8 @@ public Builder name(String name) { return this; } - public Builder genericArgs(Type... genericArgs) { - this.genericArgs = genericArgs; + public Builder typeParams(Type... typeParams) { + this.typeParams = typeParams; return this; } 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 7dc66ca479..1ce5a4806f 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 @@ -74,17 +74,17 @@ public static final class Util { public static final Type HashMap = Type.builder().pkg(PACKAGE).name("HashMap").build(); public static Type Map(Type keyType, Type valueType) { - return Map.withGenericArgs(keyType, valueType); + return Map.withTypeParams(keyType, valueType); } public static final Type Map = Type.builder().pkg(PACKAGE).name("Map").build(); public static Type MapEntry(Type keyType, Type valueType) { - return Type.builder().pkg(PACKAGE).name("Map.Entry").genericArgs(keyType, valueType).build(); + return Type.builder().pkg(PACKAGE).name("Map.Entry").typeParams(keyType, valueType).build(); } public static Type List(Type valueType) { - return Type.builder().pkg(PACKAGE).name("List").genericArgs(valueType).build(); + return Type.builder().pkg(PACKAGE).name("List").typeParams(valueType).build(); } public static final class Concurrent { @@ -96,7 +96,7 @@ public static final class Function { public static final String PACKAGE = Util.PACKAGE + ".function"; public static Type Function(Type argType, Type returnType) { - return Type.builder().pkg(PACKAGE).name("Function").genericArgs(argType, returnType).build(); + return Type.builder().pkg(PACKAGE).name("Function").typeParams(argType, returnType).build(); } } @@ -121,7 +121,7 @@ public static final class Client { public static final String PACKAGE = "org.opensearch.client"; public static Type ApiClient(Type transport, Type client) { - return ApiClient.withGenericArgs(transport, client); + return ApiClient.withTypeParams(transport, client); } public static final Type ApiClient = Type.builder().pkg(PACKAGE).name("ApiClient").build(); @@ -136,6 +136,7 @@ public static final class Json { public static final Type JsonpSerializable = Type.builder().pkg(PACKAGE).name("JsonpSerializable").build(); public static final Type ObjectBuilderDeserializer = Type.builder().pkg(PACKAGE).name("ObjectBuilderDeserializer").build(); public static final Type ObjectDeserializer = Type.builder().pkg(PACKAGE).name("ObjectDeserializer").build(); + public static final Type PlainJsonSerializable = Type.builder().pkg(PACKAGE).name("PlainJsonSerializable").build(); public static final Type UnionDeserializer = Type.builder().pkg(PACKAGE).name("UnionDeserializer").build(); } @@ -154,6 +155,11 @@ public static final class _Types { public static final class Transport { public static final String PACKAGE = Client.PACKAGE + ".transport"; public static final Type Endpoint = Type.builder().pkg(PACKAGE).name("Endpoint").build(); + + public static Type JsonEndpoint(Type requestType, Type responseType, Type errorType) { + return JsonEndpoint.withTypeParams(requestType, responseType, errorType); + } + public static final Type JsonEndpoint = Type.builder().pkg(PACKAGE).name("JsonEndpoint").build(); public static final Type OpenSearchTransport = Type.builder().pkg(PACKAGE).name("OpenSearchTransport").build(); public static final Type TransportOptions = Type.builder().pkg(PACKAGE).name("TransportOptions").build(); @@ -169,14 +175,14 @@ public static final class Util { public static final Type ApiTypeHelper = Type.builder().pkg(PACKAGE).name("ApiTypeHelper").build(); public static Type ObjectBuilder(Type type) { - return ObjectBuilder.withGenericArgs(type); + return ObjectBuilder.withTypeParams(type); } public static final Type ObjectBuilder = Type.builder().pkg(PACKAGE).name("ObjectBuilder").build(); public static final Type ObjectBuilderBase = Type.builder().pkg(PACKAGE).name("ObjectBuilderBase").build(); public static Type TaggedUnion(Type tagType, Type baseType) { - return TaggedUnion.withGenericArgs(tagType, baseType); + return TaggedUnion.withTypeParams(tagType, baseType); } public static final Type TaggedUnion = Type.builder().pkg(PACKAGE).name("TaggedUnion").build(); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiRefElement.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiRefElement.java index 55f6829628..94328a7282 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiRefElement.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiRefElement.java @@ -86,6 +86,11 @@ public > TElement resolveIn(OpenApiSpe return specification.getElement(pointer, clazz); } + @Nonnull + public JsonPointer getPointer() { + return pointer; + } + @Override public String toString() { return new ToStringBuilder(this).append("pointer", pointer).append("relativeLocation", relativeLocation).toString(); 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 ea9ab3a957..4d12ae2659 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 @@ -10,7 +10,6 @@ import static org.opensearch.client.codegen.utils.Functional.ifNonnull; -import io.swagger.v3.oas.models.media.ObjectSchema; import io.swagger.v3.oas.models.media.Schema; import java.util.HashSet; import java.util.List; @@ -28,7 +27,9 @@ public class OpenApiSchema extends OpenApiRefElement { private static final JsonPointer ANONYMOUS = JsonPointer.of(""); - public static final OpenApiSchema ANONYMOUS_OBJECT = new OpenApiSchema(null, ANONYMOUS.append("object"), new ObjectSchema()); + public static final OpenApiSchema ANONYMOUS_OBJECT = builder().withPointer(ANONYMOUS.append("object")) + .withTypes(OpenApiSchemaType.Object) + .build(); @Nullable private final String name; @@ -59,6 +60,24 @@ public class OpenApiSchema extends OpenApiRefElement { @Nullable private final String pattern; + private OpenApiSchema(@Nonnull Builder builder) { + super(builder.parent, Objects.requireNonNull(builder.pointer, "pointer must not be null"), builder.$ref, OpenApiSchema.class); + name = builder.name; + namespace = builder.namespace; + description = builder.description; + types = builder.types; + format = builder.format; + allOf = builder.allOf; + oneOf = builder.oneOf; + enums = builder.enums; + items = builder.items; + additionalProperties = builder.additionalProperties; + properties = builder.properties; + required = builder.required; + title = builder.title; + pattern = builder.pattern; + } + protected OpenApiSchema(@Nullable OpenApiElement parent, @Nonnull JsonPointer pointer, @Nonnull Schema schema) { super(parent, pointer, schema.get$ref(), OpenApiSchema.class); @@ -230,4 +249,79 @@ public Set determineTypes() { throw new IllegalStateException("Cannot determine type for schema: " + getPointer()); } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + @Nullable + private OpenApiElement parent; + @Nullable + private JsonPointer pointer; + @Nullable + private String $ref; + @Nullable + private String name; + @Nullable + private String namespace; + @Nullable + private String description; + @Nullable + private Set types; + @Nullable + private OpenApiSchemaFormat format; + @Nullable + private List allOf; + @Nullable + private List oneOf; + @Nullable + private List enums; + @Nullable + private OpenApiSchema items; + @Nullable + private OpenApiSchema additionalProperties; + @Nullable + private Map properties; + @Nullable + private Set required; + @Nullable + private String title; + @Nullable + private String pattern; + + @Nonnull + public Builder withPointer(@Nonnull JsonPointer pointer) { + this.pointer = Objects.requireNonNull(pointer, "pointer must not be null"); + return this; + } + + @Nonnull + public Builder withTypes(OpenApiSchemaType... types) { + return withTypes(Set.of(types)); + } + + @Nonnull + public Builder withTypes(@Nullable Set types) { + this.types = types; + return this; + } + + @Nonnull + public Builder withAllOf(OpenApiSchema... allOf) { + return withAllOf(List.of(allOf)); + } + + @Nonnull + public Builder withAllOf(@Nullable List allOf) { + this.allOf = allOf; + return this; + } + + @Nonnull + public OpenApiSchema build() { + return new OpenApiSchema(this); + } + } } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 3d4c1b94ce..627af1db03 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -7,8 +7,10 @@ {{>ObjectShape/Getters}} +{{#hasFieldsToSerialize}} {{>ObjectShape/Serialize}} +{{/hasFieldsToSerialize}} // --------------------------------------------------------------------------------------------- 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 47f7ce70dd..2ef354df7a 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 @@ -1,46 +1,64 @@ +{{^abstract}} /** * Builder for {@link {{className}}}. */ - public static class Builder extends {{TYPES.Client.Util.ObjectBuilderBase}} implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { - {{#fields}} + public static class Builder extends +{{#extendsOtherShape}} + {{extendsType}}.AbstractBuilder +{{/extendsOtherShape}} +{{^extendsOtherShape}} + {{TYPES.Client.Util.ObjectBuilderBase}} +{{/extendsOtherShape}} + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + {{#extendsOtherShape}} + @Override + protected Builder self() { + return this; + } + {{/extendsOtherShape}} +{{/abstract}} +{{#abstract}} + protected abstract static class AbstractBuilder> extends {{TYPES.Client.Util.ObjectBuilderBase}} { +{{/abstract}} + {{#fields}} {{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}private {{type.boxed}} {{name}}; - {{/fields}} + {{/fields}} - {{#fields}} + {{#fields}} {{#type.isMap}} {{>ObjectShape/FieldDoc/Basic}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type}} map) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type}} map) { this.{{name}} = _mapPutAll(this.{{name}}, map); - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{>ObjectShape/FieldDoc/Basic}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type.mapKeyType}} key, {{type.mapValueType}} value) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.mapKeyType}} key, {{type.mapValueType}} value) { this.{{name}} = _mapPut(this.{{name}}, key, value); - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{/type.isMap}} {{#type.isList}} {{>ObjectShape/FieldDoc/ListAddAll}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type}} list) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type}} list) { this.{{name}} = _listAddAll(this.{{name}}, list); - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{>ObjectShape/FieldDoc/ListAdd}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type.listValueType}} value, {{type.listValueType}}... values) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.listValueType}} value, {{type.listValueType}}... values) { this.{{name}} = _listAdd(this.{{name}}, value, values); - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{#type.listValueType.hasBuilder}} {{>ObjectShape/FieldDoc/ListAddBuilderFn}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type.listValueType.builderFnType}} fn) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.listValueType.builderFnType}} fn) { return {{name}}(fn.apply(new {{type.listValueType.builderType}}()).build()); } {{/type.listValueType.hasBuilder}} @@ -48,21 +66,22 @@ {{^type.isListOrMap}} {{>ObjectShape/FieldDoc/Basic}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}{{type}} value) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}{{type}} value) { this.{{name}} = value; - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{#type.hasBuilder}} {{>ObjectShape/FieldDoc/Basic}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type.builderFnType}} fn) { - return this.{{name}}(fn.apply(new {{type.builderType}}()).build()); + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.builderFnType}} fn) { + return {{name}}(fn.apply(new {{type.builderType}}()).build()); } {{/type.hasBuilder}} {{/type.isListOrMap}} - {{/fields}} + {{/fields}} + {{^abstract}} /** * Builds a {@link {{className}}}. * @@ -74,4 +93,8 @@ return new {{className}}(this); } + {{/abstract}} + {{#abstract}} + protected abstract BuilderT self(); + {{/abstract}} } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache index 92995e9d00..d526639524 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache @@ -1,4 +1,12 @@ +{{^abstract}} private {{className}}(Builder builder) { +{{/abstract}} +{{#abstract}} + protected {{className}}(AbstractBuilder builder) { +{{/abstract}} +{{#extendsOtherShape}} + super(builder); +{{/extendsOtherShape}} {{#fields}} {{#type.isListOrMap}} {{#required}} @@ -18,7 +26,9 @@ {{/type.isListOrMap}} {{/fields}} } +{{^abstract}} public static {{className}} of({{type.builderFnType}} fn) { return fn.apply(new Builder()).build(); - } \ No newline at end of file + } +{{/abstract}} \ 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 42966164a4..366d666744 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 @@ -1,11 +1,19 @@ +{{^abstract}} /** * Json deserializer for {@link {{className}}} */ public static final {{TYPES.Client.Json.JsonpDeserializer}}<{{className}}> _DESERIALIZER = {{TYPES.Client.Json.ObjectBuilderDeserializer}}.lazy(Builder::new, {{className}}::setup{{className}}Deserializer); protected static void setup{{className}}Deserializer({{TYPES.Client.Json.ObjectDeserializer}}<{{type.builderType}}> op) { +{{/abstract}} +{{#abstract}} + protected static > void setup{{className}}Deserializer({{TYPES.Client.Json.ObjectDeserializer}} op) { +{{/abstract}} + {{#extendsOtherShape}} + {{extendsType}}.setup{{extendsType.name}}Deserializer(op); + {{/extendsOtherShape}} {{#bodyFields}} - op.add(Builder::{{name}}, {{#type}}{{>Type/deserializer}}{{/type}}, {{#quoted}}{{wireName}}{{/quoted}}); + op.add({{#abstract}}Abstract{{/abstract}}Builder::{{name}}, {{#type}}{{>Type/deserializer}}{{/type}}, {{#quoted}}{{wireName}}{{/quoted}}); {{/bodyFields}} {{#additionalPropertiesField}} op.setUnknownFieldHandler((builder, name, parser, mapper) -> { diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache index 332d7bfb4a..851ccc468e 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache @@ -1 +1,6 @@ -* {{#required}}Required - {{/required}}{{#description}}{{.}}
{{/description}}API name: {@code {{wireName}}} \ No newline at end of file +{{^isAdditionalProperties}} +* {{#required}}Required - {{/required}}{{#description}}{{.}}

{{/description}}API name: {@code {{wireName}}}{{#description}}

{{/description}} +{{/isAdditionalProperties}} +{{#isAdditionalProperties}} +* {{description}} +{{/isAdditionalProperties}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache index 65cb2a3aa7..d8720ba088 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache @@ -1,4 +1,5 @@ /** {{>ObjectShape/FieldDoc/BasicInner}} + *

Adds one or more values to {{name}}.

*/ \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache index 9f38e2fdba..2894d9549d 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache @@ -1,4 +1,5 @@ /** {{>ObjectShape/FieldDoc/BasicInner}} + *

Adds all elements of list to {{name}}.

*/ \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache index 72123b3e31..867d0eca28 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache @@ -1,4 +1,5 @@ /** {{>ObjectShape/FieldDoc/BasicInner}} + *

Adds a value to {{name}} using a builder lambda.

*/ \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache index 2a2e1e914c..56e993fa67 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache @@ -1,3 +1,4 @@ +{{^extendsOtherType}} /** * Serialize this object to JSON. */ @@ -8,6 +9,7 @@ generator.writeEnd(); } +{{/extendsOtherType}} protected void serializeInternal({{TYPES.Jakarta.Json.Stream.JsonGenerator}} generator, {{TYPES.Client.Json.JsonpMapper}} mapper) { {{#additionalPropertiesField}} {{#type.directSerializer}}this.{{name}}{{/type.directSerializer}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/ClassDeclaration.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/ClassDeclaration.mustache index ee29f712fb..fdb7a05eea 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/ClassDeclaration.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/ClassDeclaration.mustache @@ -11,4 +11,4 @@ @{{.}} {{/annotations}} @{{TYPES.Javax.Annotation.Generated}}("org.opensearch.client.codegen.CodeGenerator") -public {{classKind}} {{className}}{{#extendsType}} extends {{.}}{{/extendsType}}{{#implementsTypes}}{{#-first}} implements{{/-first}} {{.}}{{^-last}},{{/-last}}{{/implementsTypes}} +public {{#abstract}}abstract {{/abstract}}{{classKind}} {{className}}{{#extendsType}} extends {{.}}{{/extendsType}}{{#implementsTypes}}{{#-first}} implements{{/-first}} {{.}}{{^-last}},{{/-last}}{{/implementsTypes}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index 99a3039a73..3b21b2216e 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -77,16 +77,20 @@ {{#hasQueryParams}} request -> { {{TYPES.Java.Util.Map}} params = new {{TYPES.Java.Util.HashMap}}<>(); - {{#queryParams}} + {{#queryParams}} + {{^required}} {{#type.isListOrMap}} if ({{TYPES.Client.Util.ApiTypeHelper}}.isDefined(request.{{name}})) { {{/type.isListOrMap}} {{^type.isListOrMap}} if (request.{{name}} != null) { {{/type.isListOrMap}} + {{/required}} params.put({{#quoted}}{{wireName}}{{/quoted}}, {{#type.queryParamify}}request.{{name}}{{/type.queryParamify}}); + {{^required}} } - {{/queryParams}} + {{/required}} + {{/queryParams}} return params; }, {{/hasQueryParams}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache index 52c4913328..61fb38b72b 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache @@ -1,12 +1,12 @@ {{#isPrimitive}} - JsonpDeserializer.{{#toLower}}{{boxed.name}}{{/toLower}}Deserializer() + {{TYPES.Client.Json.JsonpDeserializer}}.{{#toLower}}{{boxed.name}}{{/toLower}}Deserializer() {{/isPrimitive}} {{^isPrimitive}} {{#isList}} - JsonpDeserializer.arrayDeserializer({{#listValueType}}{{>Type/deserializer}}{{/listValueType}}) + {{TYPES.Client.Json.JsonpDeserializer}}.arrayDeserializer({{#listValueType}}{{>Type/deserializer}}{{/listValueType}}) {{/isList}} {{#isMap}} - JsonpDeserializer.stringMapDeserializer({{#mapValueType}}{{>Type/deserializer}}{{/mapValueType}}) + {{TYPES.Client.Json.JsonpDeserializer}}.stringMapDeserializer({{#mapValueType}}{{>Type/deserializer}}{{/mapValueType}}) {{/isMap}} {{^isListOrMap}} {{name}}._DESERIALIZER From edbafe2433165812eb7c8622d7be977ece155f56 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 08:54:06 +1200 Subject: [PATCH 6/6] Bump org.eclipse.parsson:parsson from 1.1.6 to 1.1.7 (#1125) * Bump org.eclipse.parsson:parsson from 1.1.6 to 1.1.7 Bumps [org.eclipse.parsson:parsson](https://github.com/eclipse-ee4j/parsson) from 1.1.6 to 1.1.7. - [Release notes](https://github.com/eclipse-ee4j/parsson/releases) - [Commits](https://github.com/eclipse-ee4j/parsson/compare/1.1.6...1.1.7) --- updated-dependencies: - dependency-name: org.eclipse.parsson:parsson dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 3 ++- java-client/build.gradle.kts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 441725cac1..c10e80a4e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies - Bumps `org.junit:junit-bom` from 5.10.2 to 5.10.3 - Bumps `org.owasp.dependencycheck` from 10.0.2 to 10.0.3 +- Bumps `org.eclipse.parsson:parsson` from 1.1.6 to 1.1.7 This section is for maintaining a changelog for all breaking changes for the client that cannot be released in the 2.x line. All other non-breaking changes should be added to [Unreleased 2.x] section. @@ -517,4 +518,4 @@ This section is for maintaining a changelog for all breaking changes for the cli [2.5.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.4.0...v2.5.0 [2.4.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.3.0...v2.4.0 [2.3.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.2.0...v2.3.0 -[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 +[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 \ No newline at end of file diff --git a/java-client/build.gradle.kts b/java-client/build.gradle.kts index ea16e67199..2f3144bd73 100644 --- a/java-client/build.gradle.kts +++ b/java-client/build.gradle.kts @@ -198,7 +198,7 @@ dependencies { // Needed even if using Jackson to have an implementation of the Jsonp object model // EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 // https://github.com/eclipse-ee4j/parsson - api("org.eclipse.parsson:parsson:1.1.6") + api("org.eclipse.parsson:parsson:1.1.7") // EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 // http://json-b.net/