From 9e9dac4b530fe9f5b2d1dcc702ca20cd0287120d Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Wed, 4 Oct 2023 20:35:22 +0000 Subject: [PATCH] Enabling spotless for remaining opensearch module Signed-off-by: Vacha Shah --- java-client/build.gradle.kts | 2 +- .../java/org/opensearch/client/ApiClient.java | 7 +- .../opensearch/OpenSearchAsyncClient.java | 3011 +++++++++-------- .../client/opensearch/OpenSearchClient.java | 2959 ++++++++-------- .../opensearch/watcher/HourAndMinute.java | 295 +- .../client/opensearch/watcher/TimeOfDay.java | 244 +- .../opensearch/watcher/TimeOfDayBuilders.java | 19 +- 7 files changed, 3366 insertions(+), 3171 deletions(-) diff --git a/java-client/build.gradle.kts b/java-client/build.gradle.kts index a5f1922c77..c54dfd3bc9 100644 --- a/java-client/build.gradle.kts +++ b/java-client/build.gradle.kts @@ -272,7 +272,7 @@ tasks.withType { spotless { java { - target("**/json/**/*.java", "**/transport/**/*.java", "**/util/**/*.java", "**/_types/**/*.java", "**/cat/**/*.java", "**/cluster/**/*.java", "**/core/**/*.java", "**/dangling_indices/**/*.java", "**/features/**/*.java", "**/ingest/**/*.java", "**/shutdown/**/*.java", "**/tasks/**/*.java", "**/indices/**/*.java", "**/nodes/**/*.java", "**/snapshot/**/*.java") + target("**/json/**/*.java", "**/transport/**/*.java", "**/util/**/*.java", "**/main/**/opensearch/**/*.java") // Use the default importOrder configuration importOrder() diff --git a/java-client/src/main/java/org/opensearch/client/ApiClient.java b/java-client/src/main/java/org/opensearch/client/ApiClient.java index 1938dea4bb..327fc235ec 100644 --- a/java-client/src/main/java/org/opensearch/client/ApiClient.java +++ b/java-client/src/main/java/org/opensearch/client/ApiClient.java @@ -32,12 +32,11 @@ package org.opensearch.client; -import org.opensearch.client.transport.TransportOptions; -import org.opensearch.client.transport.Transport; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapperBase; - -import javax.annotation.Nullable; +import org.opensearch.client.transport.Transport; +import org.opensearch.client.transport.TransportOptions; public abstract class ApiClient> { diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java index 0aa60b542c..5d869c6f59 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java @@ -32,9 +32,13 @@ package org.opensearch.client.opensearch; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch.cat.OpenSearchCatAsyncClient; import org.opensearch.client.opensearch.cluster.OpenSearchClusterAsyncClient; import org.opensearch.client.opensearch.core.BulkRequest; @@ -126,1470 +130,1567 @@ import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownAsyncClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotAsyncClient; import org.opensearch.client.opensearch.tasks.OpenSearchTasksAsyncClient; -import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.transport.endpoints.BooleanResponse; import org.opensearch.client.transport.endpoints.EndpointWithResponseMapperAttr; import org.opensearch.client.util.ObjectBuilder; -import java.io.IOException; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; -import javax.annotation.Nullable; /** * Client for the namespace. */ public class OpenSearchAsyncClient extends ApiClient { - public OpenSearchAsyncClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchAsyncClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchAsyncClient(this.transport, transportOptions); - } - - // ----- Child clients - - public OpenSearchCatAsyncClient cat() { - return new OpenSearchCatAsyncClient(this.transport, this.transportOptions); - } - - - 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); - } - - public OpenSearchIndicesAsyncClient indices() { - return new OpenSearchIndicesAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchIngestAsyncClient ingest() { - return new OpenSearchIngestAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchNodesAsyncClient nodes() { - return new OpenSearchNodesAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchShutdownAsyncClient shutdown() { - return new OpenSearchShutdownAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchSnapshotAsyncClient snapshot() { - return new OpenSearchSnapshotAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchTasksAsyncClient tasks() { - return new OpenSearchTasksAsyncClient(this.transport, this.transportOptions); - } - - // ----- Endpoint: bulk - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * - */ - - public CompletableFuture bulk(BulkRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) BulkRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * @param fn - * a function that initializes a builder to create the - * {@link BulkRequest} - * - */ - - public final CompletableFuture bulk(Function> fn) - throws IOException, OpenSearchException { - return bulk(fn.apply(new BulkRequest.Builder()).build()); - } - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * - */ - - public CompletableFuture bulk() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new BulkRequest.Builder().build(), BulkRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: clear_scroll - - /** - * Explicitly clears the search context for a scroll. - * - * - */ - - public CompletableFuture clearScroll(ClearScrollRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ClearScrollRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Explicitly clears the search context for a scroll. - * - * @param fn - * a function that initializes a builder to create the - * {@link ClearScrollRequest} - * - */ - - public final CompletableFuture clearScroll( - Function> fn) - throws IOException, OpenSearchException { - return clearScroll(fn.apply(new ClearScrollRequest.Builder()).build()); - } - - /** - * Explicitly clears the search context for a scroll. - * - * - */ - - public CompletableFuture clearScroll() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new ClearScrollRequest.Builder().build(), - ClearScrollRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: count - - /** - * Returns number of documents matching a query. - * - * - */ - - public CompletableFuture count(CountRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) CountRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns number of documents matching a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link CountRequest} - * - */ - - public final CompletableFuture count(Function> fn) - throws IOException, OpenSearchException { - return count(fn.apply(new CountRequest.Builder()).build()); - } - - /** - * Returns number of documents matching a query. - * - * - */ - - public CompletableFuture count() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new CountRequest.Builder().build(), CountRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: create - - /** - * Creates a new document in the index. - *

- * Returns a 409 response when a document with a same ID already exists in the - * index. - * - * - */ - - public CompletableFuture create(CreateRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, CreateResponse, ErrorResponse> endpoint = - (JsonEndpoint, CreateResponse, ErrorResponse>) CreateRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates a new document in the index. - *

- * Returns a 409 response when a document with a same ID already exists in the - * index. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateRequest} - * - */ - - public final CompletableFuture create( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return create(fn.apply(new CreateRequest.Builder()).build()); - } - - // ----- Endpoint: create_point_in_time - - /** - * Provides low-level information about the disk utilization of a PIT by - * describing its Lucene segments. - * - * - */ - - public CompletableFuture createPit(CreatePitRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint) CreatePitRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Provides low-level information about the disk utilization of a PIT by - * describing its Lucene segments. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreatePitRequest} - * - */ - - public final CompletableFuture createPit( - Function> fn) - throws IOException, OpenSearchException { - return createPit(fn.apply(new CreatePitRequest.Builder()).build()); - } - - // ----- Endpoint: delete - - /** - * Removes a document from the index. - * - * - */ - - public CompletableFuture delete(DeleteRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Removes a document from the index. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteRequest} - * - */ - - public final CompletableFuture delete( - Function> fn) - throws IOException, OpenSearchException { - return delete(fn.apply(new DeleteRequest.Builder()).build()); - } - - // ----- Endpoint: delete_point_in_time - - /** - * Delete Point In Time - * - * - */ - - public CompletableFuture deletePit(DeletePitRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint) DeletePitRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Delete Point In Time - * - * @param fn - * a function that initializes a builder to create the - * {@link DeletePitRequest} - * - */ - - public final CompletableFuture deletePit( - Function> fn) - throws IOException, OpenSearchException { - return deletePit(fn.apply(new DeletePitRequest.Builder()).build()); - } - - // ----- Endpoint: delete_by_query - - /** - * Deletes documents matching the provided query. - * - * - */ - - public CompletableFuture deleteByQuery(DeleteByQueryRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteByQueryRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Deletes documents matching the provided query. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteByQueryRequest} - * - */ - - public final CompletableFuture deleteByQuery( - Function> fn) - throws IOException, OpenSearchException { - return deleteByQuery(fn.apply(new DeleteByQueryRequest.Builder()).build()); - } - - // ----- Endpoint: delete_by_query_rethrottle - - /** - * Changes the number of requests per second for a particular Delete By Query - * operation. - * - * - */ - - public CompletableFuture deleteByQueryRethrottle( - DeleteByQueryRethrottleRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - DeleteByQueryRethrottleRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Delete By Query - * operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteByQueryRethrottleRequest} - * - */ - - public final CompletableFuture deleteByQueryRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return deleteByQueryRethrottle(fn.apply(new DeleteByQueryRethrottleRequest.Builder()).build()); - } - - // ----- Endpoint: delete_script - - /** - * Deletes a script. - * - * - */ - - public CompletableFuture deleteScript(DeleteScriptRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteScriptRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Deletes a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteScriptRequest} - * - */ - - public final CompletableFuture deleteScript( - Function> fn) - throws IOException, OpenSearchException { - return deleteScript(fn.apply(new DeleteScriptRequest.Builder()).build()); - } - - // ----- Endpoint: exists - - /** - * Returns information about whether a document exists in an index. - * - * - */ - - public CompletableFuture exists(ExistsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ExistsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a document exists in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsRequest} - * - */ - - public final CompletableFuture exists( - Function> fn) - throws IOException, OpenSearchException { - return exists(fn.apply(new ExistsRequest.Builder()).build()); - } - - // ----- Endpoint: exists_source - - /** - * Returns information about whether a document source exists in an index. - * - * - */ - - public CompletableFuture existsSource(ExistsSourceRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ExistsSourceRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a document source exists in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsSourceRequest} - * - */ - - public final CompletableFuture existsSource( - Function> fn) - throws IOException, OpenSearchException { - return existsSource(fn.apply(new ExistsSourceRequest.Builder()).build()); - } - - // ----- Endpoint: explain - - /** - * Returns information about why a specific matches (or doesn't match) a query. - * - * - */ - - public CompletableFuture> explain(ExplainRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) ExplainRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.explain.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about why a specific matches (or doesn't match) a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExplainRequest} - * - */ - - public final CompletableFuture> explain( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return explain(fn.apply(new ExplainRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: field_caps - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - */ - - public CompletableFuture fieldCaps(FieldCapsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) FieldCapsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link FieldCapsRequest} - * - */ - - public final CompletableFuture fieldCaps( - Function> fn) - throws IOException, OpenSearchException { - return fieldCaps(fn.apply(new FieldCapsRequest.Builder()).build()); - } - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * - */ - - public CompletableFuture fieldCaps() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new FieldCapsRequest.Builder().build(), FieldCapsRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get - - /** - * Returns a document. - * - * - */ - - public CompletableFuture> get(GetRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) GetRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.get.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns a document. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetRequest} - * - */ - - public final CompletableFuture> get( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return get(fn.apply(new GetRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: get_script - - /** - * Returns a script. - * - * - */ - - public CompletableFuture getScript(GetScriptRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) GetScriptRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetScriptRequest} - * - */ - - public final CompletableFuture getScript( - Function> fn) - throws IOException, OpenSearchException { - return getScript(fn.apply(new GetScriptRequest.Builder()).build()); - } - - // ----- Endpoint: get_script_context - - /** - * Returns all script contexts. - * - * - */ - public CompletableFuture getScriptContext() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(GetScriptContextRequest._INSTANCE, GetScriptContextRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get_script_languages - - /** - * Returns available script types, languages and contexts - * - * - */ - public CompletableFuture getScriptLanguages() - throws IOException, OpenSearchException { - return this.transport.performRequestAsync(GetScriptLanguagesRequest._INSTANCE, - GetScriptLanguagesRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: get_source - - /** - * Returns the source of a document. - * - * - */ - - public CompletableFuture> getSource(GetSourceRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) GetSourceRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.get_source.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns the source of a document. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetSourceRequest} - * - */ - - public final CompletableFuture> getSource( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return getSource(fn.apply(new GetSourceRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: index - - /** - * Creates or updates a document in an index. - * - * - */ - - public CompletableFuture index(IndexRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, IndexResponse, ErrorResponse> endpoint = - (JsonEndpoint, IndexResponse, ErrorResponse>) IndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates a document in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link IndexRequest} - * - */ - - public final CompletableFuture index( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return index(fn.apply(new IndexRequest.Builder()).build()); - } - - // ----- Endpoint: info - - /** - * Returns basic information about the cluster. - * - * - */ - public CompletableFuture info() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: list_point_in_time - - /** - * List all Point In Time - * - * - */ - - public CompletableFuture listAllPit() - throws IOException, OpenSearchException { - return this.transport.performRequestAsync(ListAllPitRequest._INSTANCE, ListAllPitRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: mget - - /** - * Allows to get multiple documents in one request. - * - * - */ - - public CompletableFuture> mget(MgetRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) MgetRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.mget.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to get multiple documents in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MgetRequest} - * - */ - - public final CompletableFuture> mget( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return mget(fn.apply(new MgetRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: msearch - - /** - * Allows to execute several search operations in one request. - * - * - */ - - public CompletableFuture> msearch(MsearchRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) MsearchRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.msearch.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to execute several search operations in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MsearchRequest} - * - */ - - public final CompletableFuture> msearch( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return msearch(fn.apply(new MsearchRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: msearch_template - - /** - * Allows to execute several search template operations in one request. - * - * - */ - - public CompletableFuture> msearchTemplate( - MsearchTemplateRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - MsearchTemplateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.msearch_template.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to execute several search template operations in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MsearchTemplateRequest} - * - */ - - public final CompletableFuture> msearchTemplate( - Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return msearchTemplate(fn.apply(new MsearchTemplateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: mtermvectors - - /** - * Returns multiple termvectors in one request. - * - * - */ - - public CompletableFuture mtermvectors(MtermvectorsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) MtermvectorsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns multiple termvectors in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MtermvectorsRequest} - * - */ - - public final CompletableFuture mtermvectors( - Function> fn) - throws IOException, OpenSearchException { - return mtermvectors(fn.apply(new MtermvectorsRequest.Builder()).build()); - } - - /** - * Returns multiple termvectors in one request. - * - * - */ - - public CompletableFuture mtermvectors() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new MtermvectorsRequest.Builder().build(), - MtermvectorsRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: ping - - /** - * Returns whether the cluster is running. - * - * - */ - public CompletableFuture ping() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(PingRequest._INSTANCE, PingRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: put_script - - /** - * Creates or updates a script. - * - * - */ - - public CompletableFuture putScript(PutScriptRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) PutScriptRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link PutScriptRequest} - * - */ - - public final CompletableFuture putScript( - Function> fn) - throws IOException, OpenSearchException { - return putScript(fn.apply(new PutScriptRequest.Builder()).build()); - } - - // ----- Endpoint: rank_eval - - /** - * Allows to evaluate the quality of ranked search results over a set of typical - * search queries - * - * - */ - - public CompletableFuture rankEval(RankEvalRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) RankEvalRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to evaluate the quality of ranked search results over a set of typical - * search queries - * - * @param fn - * a function that initializes a builder to create the - * {@link RankEvalRequest} - * - */ - - public final CompletableFuture rankEval( - Function> fn) - throws IOException, OpenSearchException { - return rankEval(fn.apply(new RankEvalRequest.Builder()).build()); - } - - // ----- Endpoint: reindex - - /** - * Allows to copy documents from one index to another, optionally filtering the - * source documents by a query, changing the destination index settings, or - * fetching the documents from a remote cluster. - * - * - */ - - public CompletableFuture reindex(ReindexRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ReindexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to copy documents from one index to another, optionally filtering the - * source documents by a query, changing the destination index settings, or - * fetching the documents from a remote cluster. - * - * @param fn - * a function that initializes a builder to create the - * {@link ReindexRequest} - * - */ - - public final CompletableFuture reindex( - Function> fn) - throws IOException, OpenSearchException { - return reindex(fn.apply(new ReindexRequest.Builder()).build()); - } - - /** - * Allows to copy documents from one index to another, optionally filtering the - * source documents by a query, changing the destination index settings, or - * fetching the documents from a remote cluster. - * - * - */ - - public CompletableFuture reindex() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new ReindexRequest.Builder().build(), ReindexRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: reindex_rethrottle - - /** - * Changes the number of requests per second for a particular Reindex operation. - * - * - */ - - public CompletableFuture reindexRethrottle(ReindexRethrottleRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - ReindexRethrottleRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Reindex operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link ReindexRethrottleRequest} - * - */ - - public final CompletableFuture reindexRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return reindexRethrottle(fn.apply(new ReindexRethrottleRequest.Builder()).build()); - } - - // ----- Endpoint: render_search_template - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public CompletableFuture renderSearchTemplate(RenderSearchTemplateRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - RenderSearchTemplateRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * @param fn - * a function that initializes a builder to create the - * {@link RenderSearchTemplateRequest} - * - */ - - public final CompletableFuture renderSearchTemplate( - Function> fn) - throws IOException, OpenSearchException { - return renderSearchTemplate(fn.apply(new RenderSearchTemplateRequest.Builder()).build()); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public CompletableFuture renderSearchTemplate() - throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new RenderSearchTemplateRequest.Builder().build(), - RenderSearchTemplateRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: scripts_painless_execute - - /** - * Allows an arbitrary script to be executed and a result to be returned - * - * - */ - - public CompletableFuture> scriptsPainlessExecute( - ScriptsPainlessExecuteRequest request, Class tResultClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - ScriptsPainlessExecuteRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.scripts_painless_execute.TResult", - getDeserializer(tResultClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows an arbitrary script to be executed and a result to be returned - * - * @param fn - * a function that initializes a builder to create the - * {@link ScriptsPainlessExecuteRequest} - * - */ - - public final CompletableFuture> scriptsPainlessExecute( - Function> fn, - Class tResultClass) throws IOException, OpenSearchException { - return scriptsPainlessExecute(fn.apply(new ScriptsPainlessExecuteRequest.Builder()).build(), tResultClass); - } - - // ----- Endpoint: scroll - - /** - * Allows to retrieve a large numbers of results from a single search request. - * - */ - - public CompletableFuture> scroll(ScrollRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) ScrollRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.scroll.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to retrieve a large numbers of results from a single search request. - * - * @param fn - * a function that initializes a builder to create the - * {@link ScrollRequest} - */ - - public final CompletableFuture> scroll( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return scroll(fn.apply(new ScrollRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: search - - /** - * Returns results matching a query. - * - * - */ - - public CompletableFuture> search(SearchRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) SearchRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.search.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns results matching a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchRequest} - * - */ - - public final CompletableFuture> search( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return search(fn.apply(new SearchRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: search_shards - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * - */ - - public CompletableFuture searchShards(SearchShardsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) SearchShardsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchShardsRequest} - * - */ - - public final CompletableFuture searchShards( - Function> fn) - throws IOException, OpenSearchException { - return searchShards(fn.apply(new SearchShardsRequest.Builder()).build()); - } - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * - */ - - public CompletableFuture searchShards() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new SearchShardsRequest.Builder().build(), - SearchShardsRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: search_template - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public CompletableFuture> searchTemplate( - SearchTemplateRequest request, Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - SearchTemplateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.search_template.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchTemplateRequest} - * - */ - - public final CompletableFuture> searchTemplate( - Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: terms_enum - - /** - * The terms enum API can be used to discover terms in the index that begin with - * the provided string. It is designed for low-latency look-ups used in - * auto-complete scenarios. - * - * - */ - - public CompletableFuture termsEnum(TermsEnumRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) TermsEnumRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * The terms enum API can be used to discover terms in the index that begin with - * the provided string. It is designed for low-latency look-ups used in - * auto-complete scenarios. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermsEnumRequest} - * - */ - - public final CompletableFuture termsEnum( - Function> fn) - throws IOException, OpenSearchException { - return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); - } - - // ----- Endpoint: termvectors - - /** - * Returns information and statistics about terms in the fields of a particular - * document. - * - * - */ - - public CompletableFuture termvectors(TermvectorsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, TermvectorsResponse, ErrorResponse> endpoint = - (JsonEndpoint, TermvectorsResponse, ErrorResponse>) TermvectorsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information and statistics about terms in the fields of a particular - * document. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermvectorsRequest} - * - */ - - public final CompletableFuture termvectors( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return termvectors(fn.apply(new TermvectorsRequest.Builder()).build()); - } - - // ----- Endpoint: update - - /** - * Updates a document with a script or partial document. - * - * - */ - - public CompletableFuture> update( - UpdateRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, UpdateResponse, ErrorResponse> endpoint = - (JsonEndpoint, UpdateResponse, ErrorResponse>) UpdateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.update.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Updates a document with a script or partial document. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateRequest} - * - */ - - public final CompletableFuture> update( - Function, - ObjectBuilder>> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return update(fn.apply(new UpdateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: update_by_query - - /** - * Performs an update on every document in the index without changing the - * source, for example to pick up a mapping change. - * - * - */ - - public CompletableFuture updateByQuery(UpdateByQueryRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - UpdateByQueryRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Performs an update on every document in the index without changing the - * source, for example to pick up a mapping change. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateByQueryRequest} - * - */ - - public final CompletableFuture updateByQuery( - Function> fn) - throws IOException, OpenSearchException { - return updateByQuery(fn.apply(new UpdateByQueryRequest.Builder()).build()); - } - - // ----- Endpoint: update_by_query_rethrottle - - /** - * Changes the number of requests per second for a particular Update By Query - * operation. - * - * - */ - - public CompletableFuture updateByQueryRethrottle( - UpdateByQueryRethrottleRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - UpdateByQueryRethrottleRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Update By Query - * operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateByQueryRethrottleRequest} - * - */ - - public final CompletableFuture updateByQueryRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return updateByQueryRethrottle(fn.apply(new UpdateByQueryRethrottleRequest.Builder()).build()); - } + public OpenSearchAsyncClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchAsyncClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public OpenSearchAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchAsyncClient(this.transport, transportOptions); + } + + // ----- Child clients + + public OpenSearchCatAsyncClient cat() { + return new OpenSearchCatAsyncClient(this.transport, this.transportOptions); + } + + 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); + } + + public OpenSearchIndicesAsyncClient indices() { + return new OpenSearchIndicesAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchIngestAsyncClient ingest() { + return new OpenSearchIngestAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchNodesAsyncClient nodes() { + return new OpenSearchNodesAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchShutdownAsyncClient shutdown() { + return new OpenSearchShutdownAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchSnapshotAsyncClient snapshot() { + return new OpenSearchSnapshotAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchTasksAsyncClient tasks() { + return new OpenSearchTasksAsyncClient(this.transport, this.transportOptions); + } + + // ----- Endpoint: bulk + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * + */ + + public CompletableFuture bulk(BulkRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + BulkRequest, + BulkResponse, + ErrorResponse>) BulkRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * @param fn + * a function that initializes a builder to create the + * {@link BulkRequest} + * + */ + + public final CompletableFuture bulk(Function> fn) throws IOException, + OpenSearchException { + return bulk(fn.apply(new BulkRequest.Builder()).build()); + } + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * + */ + + public CompletableFuture bulk() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(new BulkRequest.Builder().build(), BulkRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: clear_scroll + + /** + * Explicitly clears the search context for a scroll. + * + * + */ + + public CompletableFuture clearScroll(ClearScrollRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ClearScrollRequest, + ClearScrollResponse, + ErrorResponse>) ClearScrollRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Explicitly clears the search context for a scroll. + * + * @param fn + * a function that initializes a builder to create the + * {@link ClearScrollRequest} + * + */ + + public final CompletableFuture clearScroll( + Function> fn + ) throws IOException, OpenSearchException { + return clearScroll(fn.apply(new ClearScrollRequest.Builder()).build()); + } + + /** + * Explicitly clears the search context for a scroll. + * + * + */ + + public CompletableFuture clearScroll() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new ClearScrollRequest.Builder().build(), + ClearScrollRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: count + + /** + * Returns number of documents matching a query. + * + * + */ + + public CompletableFuture count(CountRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + CountRequest, + CountResponse, + ErrorResponse>) CountRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns number of documents matching a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link CountRequest} + * + */ + + public final CompletableFuture count(Function> fn) throws IOException, + OpenSearchException { + return count(fn.apply(new CountRequest.Builder()).build()); + } + + /** + * Returns number of documents matching a query. + * + * + */ + + public CompletableFuture count() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(new CountRequest.Builder().build(), CountRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: create + + /** + * Creates a new document in the index. + *

+ * Returns a 409 response when a document with a same ID already exists in the + * index. + * + * + */ + + public CompletableFuture create(CreateRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, CreateResponse, ErrorResponse> endpoint = (JsonEndpoint< + CreateRequest, + CreateResponse, + ErrorResponse>) CreateRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Creates a new document in the index. + *

+ * Returns a 409 response when a document with a same ID already exists in the + * index. + * + * @param fn + * a function that initializes a builder to create the + * {@link CreateRequest} + * + */ + + public final CompletableFuture create( + Function, ObjectBuilder>> fn + ) throws IOException, OpenSearchException { + return create(fn.apply(new CreateRequest.Builder()).build()); + } + + // ----- Endpoint: create_point_in_time + + /** + * Provides low-level information about the disk utilization of a PIT by + * describing its Lucene segments. + * + * + */ + + public CompletableFuture createPit(CreatePitRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + CreatePitRequest, + CreatePitResponse, + ErrorResponse>) CreatePitRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Provides low-level information about the disk utilization of a PIT by + * describing its Lucene segments. + * + * @param fn + * a function that initializes a builder to create the + * {@link CreatePitRequest} + * + */ + + public final CompletableFuture createPit(Function> fn) + throws IOException, OpenSearchException { + return createPit(fn.apply(new CreatePitRequest.Builder()).build()); + } + + // ----- Endpoint: delete + + /** + * Removes a document from the index. + * + * + */ + + public CompletableFuture delete(DeleteRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteRequest, + DeleteResponse, + ErrorResponse>) DeleteRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Removes a document from the index. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteRequest} + * + */ + + public final CompletableFuture delete(Function> fn) + throws IOException, OpenSearchException { + return delete(fn.apply(new DeleteRequest.Builder()).build()); + } + + // ----- Endpoint: delete_point_in_time + + /** + * Delete Point In Time + * + * + */ + + public CompletableFuture deletePit(DeletePitRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeletePitRequest, + DeletePitResponse, + ErrorResponse>) DeletePitRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Delete Point In Time + * + * @param fn + * a function that initializes a builder to create the + * {@link DeletePitRequest} + * + */ + + public final CompletableFuture deletePit(Function> fn) + throws IOException, OpenSearchException { + return deletePit(fn.apply(new DeletePitRequest.Builder()).build()); + } + + // ----- Endpoint: delete_by_query + + /** + * Deletes documents matching the provided query. + * + * + */ + + public CompletableFuture deleteByQuery(DeleteByQueryRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteByQueryRequest, + DeleteByQueryResponse, + ErrorResponse>) DeleteByQueryRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Deletes documents matching the provided query. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteByQueryRequest} + * + */ + + public final CompletableFuture deleteByQuery( + Function> fn + ) throws IOException, OpenSearchException { + return deleteByQuery(fn.apply(new DeleteByQueryRequest.Builder()).build()); + } + + // ----- Endpoint: delete_by_query_rethrottle + + /** + * Changes the number of requests per second for a particular Delete By Query + * operation. + * + * + */ + + public CompletableFuture deleteByQueryRethrottle(DeleteByQueryRethrottleRequest request) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteByQueryRethrottleRequest, + DeleteByQueryRethrottleResponse, + ErrorResponse>) DeleteByQueryRethrottleRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Delete By Query + * operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteByQueryRethrottleRequest} + * + */ + + public final CompletableFuture deleteByQueryRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return deleteByQueryRethrottle(fn.apply(new DeleteByQueryRethrottleRequest.Builder()).build()); + } + + // ----- Endpoint: delete_script + + /** + * Deletes a script. + * + * + */ + + public CompletableFuture deleteScript(DeleteScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteScriptRequest, + DeleteScriptResponse, + ErrorResponse>) DeleteScriptRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Deletes a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteScriptRequest} + * + */ + + public final CompletableFuture deleteScript( + Function> fn + ) throws IOException, OpenSearchException { + return deleteScript(fn.apply(new DeleteScriptRequest.Builder()).build()); + } + + // ----- Endpoint: exists + + /** + * Returns information about whether a document exists in an index. + * + * + */ + + public CompletableFuture exists(ExistsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ExistsRequest, + BooleanResponse, + ErrorResponse>) ExistsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information about whether a document exists in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExistsRequest} + * + */ + + public final CompletableFuture exists(Function> fn) + throws IOException, OpenSearchException { + return exists(fn.apply(new ExistsRequest.Builder()).build()); + } + + // ----- Endpoint: exists_source + + /** + * Returns information about whether a document source exists in an index. + * + * + */ + + public CompletableFuture existsSource(ExistsSourceRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ExistsSourceRequest, + BooleanResponse, + ErrorResponse>) ExistsSourceRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information about whether a document source exists in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExistsSourceRequest} + * + */ + + public final CompletableFuture existsSource( + Function> fn + ) throws IOException, OpenSearchException { + return existsSource(fn.apply(new ExistsSourceRequest.Builder()).build()); + } + + // ----- Endpoint: explain + + /** + * Returns information about why a specific matches (or doesn't match) a query. + * + * + */ + + public CompletableFuture> explain(ExplainRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ExplainRequest, + ExplainResponse, + ErrorResponse>) ExplainRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.explain.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information about why a specific matches (or doesn't match) a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExplainRequest} + * + */ + + public final CompletableFuture> explain( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return explain(fn.apply(new ExplainRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: field_caps + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + */ + + public CompletableFuture fieldCaps(FieldCapsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + FieldCapsRequest, + FieldCapsResponse, + ErrorResponse>) FieldCapsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * @param fn + * a function that initializes a builder to create the + * {@link FieldCapsRequest} + * + */ + + public final CompletableFuture fieldCaps(Function> fn) + throws IOException, OpenSearchException { + return fieldCaps(fn.apply(new FieldCapsRequest.Builder()).build()); + } + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * + */ + + public CompletableFuture fieldCaps() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new FieldCapsRequest.Builder().build(), + FieldCapsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: get + + /** + * Returns a document. + * + * + */ + + public CompletableFuture> get(GetRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + GetRequest, + GetResponse, + ErrorResponse>) GetRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.get.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns a document. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRequest} + * + */ + + public final CompletableFuture> get( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return get(fn.apply(new GetRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: get_script + + /** + * Returns a script. + * + * + */ + + public CompletableFuture getScript(GetScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + GetScriptRequest, + GetScriptResponse, + ErrorResponse>) GetScriptRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetScriptRequest} + * + */ + + public final CompletableFuture getScript(Function> fn) + throws IOException, OpenSearchException { + return getScript(fn.apply(new GetScriptRequest.Builder()).build()); + } + + // ----- Endpoint: get_script_context + + /** + * Returns all script contexts. + * + * + */ + public CompletableFuture getScriptContext() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + GetScriptContextRequest._INSTANCE, + GetScriptContextRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: get_script_languages + + /** + * Returns available script types, languages and contexts + * + * + */ + public CompletableFuture getScriptLanguages() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + GetScriptLanguagesRequest._INSTANCE, + GetScriptLanguagesRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: get_source + + /** + * Returns the source of a document. + * + * + */ + + public CompletableFuture> getSource(GetSourceRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + GetSourceRequest, + GetSourceResponse, + ErrorResponse>) GetSourceRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.get_source.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns the source of a document. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetSourceRequest} + * + */ + + public final CompletableFuture> getSource( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return getSource(fn.apply(new GetSourceRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: index + + /** + * Creates or updates a document in an index. + * + * + */ + + public CompletableFuture index(IndexRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, IndexResponse, ErrorResponse> endpoint = (JsonEndpoint< + IndexRequest, + IndexResponse, + ErrorResponse>) IndexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Creates or updates a document in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link IndexRequest} + * + */ + + public final CompletableFuture index( + Function, ObjectBuilder>> fn + ) throws IOException, OpenSearchException { + return index(fn.apply(new IndexRequest.Builder()).build()); + } + + // ----- Endpoint: info + + /** + * Returns basic information about the cluster. + * + * + */ + public CompletableFuture info() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: list_point_in_time + + /** + * List all Point In Time + * + * + */ + + public CompletableFuture listAllPit() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(ListAllPitRequest._INSTANCE, ListAllPitRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: mget + + /** + * Allows to get multiple documents in one request. + * + * + */ + + public CompletableFuture> mget(MgetRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MgetRequest, + MgetResponse, + ErrorResponse>) MgetRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.mget.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to get multiple documents in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MgetRequest} + * + */ + + public final CompletableFuture> mget( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return mget(fn.apply(new MgetRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: msearch + + /** + * Allows to execute several search operations in one request. + * + * + */ + + public CompletableFuture> msearch(MsearchRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MsearchRequest, + MsearchResponse, + ErrorResponse>) MsearchRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.msearch.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to execute several search operations in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MsearchRequest} + * + */ + + public final CompletableFuture> msearch( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return msearch(fn.apply(new MsearchRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: msearch_template + + /** + * Allows to execute several search template operations in one request. + * + * + */ + + public CompletableFuture> msearchTemplate( + MsearchTemplateRequest request, + Class tDocumentClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MsearchTemplateRequest, + MsearchTemplateResponse, + ErrorResponse>) MsearchTemplateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.msearch_template.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to execute several search template operations in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MsearchTemplateRequest} + * + */ + + public final CompletableFuture> msearchTemplate( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return msearchTemplate(fn.apply(new MsearchTemplateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: mtermvectors + + /** + * Returns multiple termvectors in one request. + * + * + */ + + public CompletableFuture mtermvectors(MtermvectorsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + MtermvectorsRequest, + MtermvectorsResponse, + ErrorResponse>) MtermvectorsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns multiple termvectors in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MtermvectorsRequest} + * + */ + + public final CompletableFuture mtermvectors( + Function> fn + ) throws IOException, OpenSearchException { + return mtermvectors(fn.apply(new MtermvectorsRequest.Builder()).build()); + } + + /** + * Returns multiple termvectors in one request. + * + * + */ + + public CompletableFuture mtermvectors() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new MtermvectorsRequest.Builder().build(), + MtermvectorsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: ping + + /** + * Returns whether the cluster is running. + * + * + */ + public CompletableFuture ping() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(PingRequest._INSTANCE, PingRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: put_script + + /** + * Creates or updates a script. + * + * + */ + + public CompletableFuture putScript(PutScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + PutScriptRequest, + PutScriptResponse, + ErrorResponse>) PutScriptRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Creates or updates a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link PutScriptRequest} + * + */ + + public final CompletableFuture putScript(Function> fn) + throws IOException, OpenSearchException { + return putScript(fn.apply(new PutScriptRequest.Builder()).build()); + } + + // ----- Endpoint: rank_eval + + /** + * Allows to evaluate the quality of ranked search results over a set of typical + * search queries + * + * + */ + + public CompletableFuture rankEval(RankEvalRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + RankEvalRequest, + RankEvalResponse, + ErrorResponse>) RankEvalRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to evaluate the quality of ranked search results over a set of typical + * search queries + * + * @param fn + * a function that initializes a builder to create the + * {@link RankEvalRequest} + * + */ + + public final CompletableFuture rankEval(Function> fn) + throws IOException, OpenSearchException { + return rankEval(fn.apply(new RankEvalRequest.Builder()).build()); + } + + // ----- Endpoint: reindex + + /** + * Allows to copy documents from one index to another, optionally filtering the + * source documents by a query, changing the destination index settings, or + * fetching the documents from a remote cluster. + * + * + */ + + public CompletableFuture reindex(ReindexRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ReindexRequest, + ReindexResponse, + ErrorResponse>) ReindexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to copy documents from one index to another, optionally filtering the + * source documents by a query, changing the destination index settings, or + * fetching the documents from a remote cluster. + * + * @param fn + * a function that initializes a builder to create the + * {@link ReindexRequest} + * + */ + + public final CompletableFuture reindex(Function> fn) + throws IOException, OpenSearchException { + return reindex(fn.apply(new ReindexRequest.Builder()).build()); + } + + /** + * Allows to copy documents from one index to another, optionally filtering the + * source documents by a query, changing the destination index settings, or + * fetching the documents from a remote cluster. + * + * + */ + + public CompletableFuture reindex() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(new ReindexRequest.Builder().build(), ReindexRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: reindex_rethrottle + + /** + * Changes the number of requests per second for a particular Reindex operation. + * + * + */ + + public CompletableFuture reindexRethrottle(ReindexRethrottleRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ReindexRethrottleRequest, + ReindexRethrottleResponse, + ErrorResponse>) ReindexRethrottleRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Reindex operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link ReindexRethrottleRequest} + * + */ + + public final CompletableFuture reindexRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return reindexRethrottle(fn.apply(new ReindexRethrottleRequest.Builder()).build()); + } + + // ----- Endpoint: render_search_template + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public CompletableFuture renderSearchTemplate(RenderSearchTemplateRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + RenderSearchTemplateRequest, + RenderSearchTemplateResponse, + ErrorResponse>) RenderSearchTemplateRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * @param fn + * a function that initializes a builder to create the + * {@link RenderSearchTemplateRequest} + * + */ + + public final CompletableFuture renderSearchTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return renderSearchTemplate(fn.apply(new RenderSearchTemplateRequest.Builder()).build()); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public CompletableFuture renderSearchTemplate() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new RenderSearchTemplateRequest.Builder().build(), + RenderSearchTemplateRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: scripts_painless_execute + + /** + * Allows an arbitrary script to be executed and a result to be returned + * + * + */ + + public CompletableFuture> scriptsPainlessExecute( + ScriptsPainlessExecuteRequest request, + Class tResultClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ScriptsPainlessExecuteRequest, + ScriptsPainlessExecuteResponse, + ErrorResponse>) ScriptsPainlessExecuteRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.scripts_painless_execute.TResult", + getDeserializer(tResultClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows an arbitrary script to be executed and a result to be returned + * + * @param fn + * a function that initializes a builder to create the + * {@link ScriptsPainlessExecuteRequest} + * + */ + + public final CompletableFuture> scriptsPainlessExecute( + Function> fn, + Class tResultClass + ) throws IOException, OpenSearchException { + return scriptsPainlessExecute(fn.apply(new ScriptsPainlessExecuteRequest.Builder()).build(), tResultClass); + } + + // ----- Endpoint: scroll + + /** + * Allows to retrieve a large numbers of results from a single search request. + * + */ + + public CompletableFuture> scroll(ScrollRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ScrollRequest, + ScrollResponse, + ErrorResponse>) ScrollRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.scroll.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to retrieve a large numbers of results from a single search request. + * + * @param fn + * a function that initializes a builder to create the + * {@link ScrollRequest} + */ + + public final CompletableFuture> scroll( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return scroll(fn.apply(new ScrollRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: search + + /** + * Returns results matching a query. + * + * + */ + + public CompletableFuture> search(SearchRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + SearchRequest, + SearchResponse, + ErrorResponse>) SearchRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.search.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns results matching a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchRequest} + * + */ + + public final CompletableFuture> search( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return search(fn.apply(new SearchRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: search_shards + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * + */ + + public CompletableFuture searchShards(SearchShardsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + SearchShardsRequest, + SearchShardsResponse, + ErrorResponse>) SearchShardsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchShardsRequest} + * + */ + + public final CompletableFuture searchShards( + Function> fn + ) throws IOException, OpenSearchException { + return searchShards(fn.apply(new SearchShardsRequest.Builder()).build()); + } + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * + */ + + public CompletableFuture searchShards() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new SearchShardsRequest.Builder().build(), + SearchShardsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: search_template + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public CompletableFuture> searchTemplate( + SearchTemplateRequest request, + Class tDocumentClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + SearchTemplateRequest, + SearchTemplateResponse, + ErrorResponse>) SearchTemplateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.search_template.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchTemplateRequest} + * + */ + + public final CompletableFuture> searchTemplate( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: terms_enum + + /** + * The terms enum API can be used to discover terms in the index that begin with + * the provided string. It is designed for low-latency look-ups used in + * auto-complete scenarios. + * + * + */ + + public CompletableFuture termsEnum(TermsEnumRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + TermsEnumRequest, + TermsEnumResponse, + ErrorResponse>) TermsEnumRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * The terms enum API can be used to discover terms in the index that begin with + * the provided string. It is designed for low-latency look-ups used in + * auto-complete scenarios. + * + * @param fn + * a function that initializes a builder to create the + * {@link TermsEnumRequest} + * + */ + + public final CompletableFuture termsEnum(Function> fn) + throws IOException, OpenSearchException { + return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); + } + + // ----- Endpoint: termvectors + + /** + * Returns information and statistics about terms in the fields of a particular + * document. + * + * + */ + + public CompletableFuture termvectors(TermvectorsRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, TermvectorsResponse, ErrorResponse> endpoint = (JsonEndpoint< + TermvectorsRequest, + TermvectorsResponse, + ErrorResponse>) TermvectorsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information and statistics about terms in the fields of a particular + * document. + * + * @param fn + * a function that initializes a builder to create the + * {@link TermvectorsRequest} + * + */ + + public final CompletableFuture termvectors( + Function, ObjectBuilder>> fn + ) throws IOException, OpenSearchException { + return termvectors(fn.apply(new TermvectorsRequest.Builder()).build()); + } + + // ----- Endpoint: update + + /** + * Updates a document with a script or partial document. + * + * + */ + + public CompletableFuture> update( + UpdateRequest request, + Class tDocumentClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, UpdateResponse, ErrorResponse> endpoint = (JsonEndpoint< + UpdateRequest, + UpdateResponse, + ErrorResponse>) UpdateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.update.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Updates a document with a script or partial document. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateRequest} + * + */ + + public final CompletableFuture> update( + Function, ObjectBuilder>> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return update(fn.apply(new UpdateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: update_by_query + + /** + * Performs an update on every document in the index without changing the + * source, for example to pick up a mapping change. + * + * + */ + + public CompletableFuture updateByQuery(UpdateByQueryRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + UpdateByQueryRequest, + UpdateByQueryResponse, + ErrorResponse>) UpdateByQueryRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Performs an update on every document in the index without changing the + * source, for example to pick up a mapping change. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateByQueryRequest} + * + */ + + public final CompletableFuture updateByQuery( + Function> fn + ) throws IOException, OpenSearchException { + return updateByQuery(fn.apply(new UpdateByQueryRequest.Builder()).build()); + } + + // ----- Endpoint: update_by_query_rethrottle + + /** + * Changes the number of requests per second for a particular Update By Query + * operation. + * + * + */ + + public CompletableFuture updateByQueryRethrottle(UpdateByQueryRethrottleRequest request) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + UpdateByQueryRethrottleRequest, + UpdateByQueryRethrottleResponse, + ErrorResponse>) UpdateByQueryRethrottleRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Update By Query + * operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateByQueryRethrottleRequest} + * + */ + + public final CompletableFuture updateByQueryRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return updateByQueryRethrottle(fn.apply(new UpdateByQueryRethrottleRequest.Builder()).build()); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java index 801ff279df..3b2d8d76ff 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java @@ -32,9 +32,12 @@ package org.opensearch.client.opensearch; +import java.io.IOException; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch.cat.OpenSearchCatClient; import org.opensearch.client.opensearch.cluster.OpenSearchClusterClient; import org.opensearch.client.opensearch.core.BulkRequest; @@ -126,1446 +129,1540 @@ import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotClient; import org.opensearch.client.opensearch.tasks.OpenSearchTasksClient; -import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.transport.endpoints.BooleanResponse; import org.opensearch.client.transport.endpoints.EndpointWithResponseMapperAttr; import org.opensearch.client.util.ObjectBuilder; -import java.io.IOException; -import java.util.function.Function; -import javax.annotation.Nullable; /** * Client for the namespace. */ public class OpenSearchClient extends ApiClient { - public OpenSearchClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchClient(this.transport, transportOptions); - } - - // ----- Child clients - - public OpenSearchCatClient cat() { - return new OpenSearchCatClient(this.transport, this.transportOptions); - } - - 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); - } - - public OpenSearchIndicesClient indices() { - return new OpenSearchIndicesClient(this.transport, this.transportOptions); - } - - public OpenSearchIngestClient ingest() { - return new OpenSearchIngestClient(this.transport, this.transportOptions); - } - - public OpenSearchNodesClient nodes() { - return new OpenSearchNodesClient(this.transport, this.transportOptions); - } - - public OpenSearchShutdownClient shutdown() { - return new OpenSearchShutdownClient(this.transport, this.transportOptions); - } - - public OpenSearchSnapshotClient snapshot() { - return new OpenSearchSnapshotClient(this.transport, this.transportOptions); - } - - public OpenSearchTasksClient tasks() { - return new OpenSearchTasksClient(this.transport, this.transportOptions); - } - - // ----- Endpoint: bulk - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * - */ - - public BulkResponse bulk(BulkRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) BulkRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * @param fn - * a function that initializes a builder to create the - * {@link BulkRequest} - * - */ - - public final BulkResponse bulk(Function> fn) - throws IOException, OpenSearchException { - return bulk(fn.apply(new BulkRequest.Builder()).build()); - } - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * - */ - - public BulkResponse bulk() throws IOException, OpenSearchException { - return this.transport.performRequest(new BulkRequest.Builder().build(), BulkRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: clear_scroll - - /** - * Explicitly clears the search context for a scroll. - * - * - */ - - public ClearScrollResponse clearScroll(ClearScrollRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ClearScrollRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Explicitly clears the search context for a scroll. - * - * @param fn - * a function that initializes a builder to create the - * {@link ClearScrollRequest} - * - */ - - public final ClearScrollResponse clearScroll( - Function> fn) - throws IOException, OpenSearchException { - return clearScroll(fn.apply(new ClearScrollRequest.Builder()).build()); - } - - /** - * Explicitly clears the search context for a scroll. - * - * - */ - - public ClearScrollResponse clearScroll() throws IOException, OpenSearchException { - return this.transport.performRequest(new ClearScrollRequest.Builder().build(), ClearScrollRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: count - - /** - * Returns number of documents matching a query. - * - * - */ - - public CountResponse count(CountRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) CountRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns number of documents matching a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link CountRequest} - * - */ - - public final CountResponse count(Function> fn) - throws IOException, OpenSearchException { - return count(fn.apply(new CountRequest.Builder()).build()); - } - - /** - * Returns number of documents matching a query. - * - * - */ - - public CountResponse count() throws IOException, OpenSearchException { - return this.transport.performRequest(new CountRequest.Builder().build(), CountRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: create - - /** - * Creates a new document in the index. - *

- * Returns a 409 response when a document with a same ID already exists in the - * index. - * - * - */ - - public CreateResponse create(CreateRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, CreateResponse, ErrorResponse> endpoint = - (JsonEndpoint, CreateResponse, ErrorResponse>) CreateRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates a new document in the index. - *

- * Returns a 409 response when a document with a same ID already exists in the - * index. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateRequest} - * - */ - - public final CreateResponse create( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return create(fn.apply(new CreateRequest.Builder()).build()); - } - - // ----- Endpoint: create_point_in_time - - /** - * Provides low-level information about the disk utilization of a PIT by - * describing its Lucene segments. - * - * - */ - - public CreatePitResponse createPit(CreatePitRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint) CreatePitRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Provides low-level information about the disk utilization of a PIT by - * describing its Lucene segments. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreatePitRequest} - * - */ - - public final CreatePitResponse createPit( - Function> fn) - throws IOException, OpenSearchException { - return createPit(fn.apply(new CreatePitRequest.Builder()).build()); - } - - // ----- Endpoint: delete - - /** - * Removes a document from the index. - * - * - */ - - public DeleteResponse delete(DeleteRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Removes a document from the index. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteRequest} - * - */ - - public final DeleteResponse delete(Function> fn) - throws IOException, OpenSearchException { - return delete(fn.apply(new DeleteRequest.Builder()).build()); - } - - // ----- Endpoint: delete_point_in_time - - /** - * Delete Point In Time - * - * - */ - - public DeletePitResponse deletePit(DeletePitRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint) DeletePitRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Delete Point In Time - * - * @param fn - * a function that initializes a builder to create the - * {@link DeletePitRequest} - * - */ - - public final DeletePitResponse deletePit( - Function> fn) - throws IOException, OpenSearchException { - return deletePit(fn.apply(new DeletePitRequest.Builder()).build()); - } - - // ----- Endpoint: delete_by_query - - /** - * Deletes documents matching the provided query. - * - * - */ - - public DeleteByQueryResponse deleteByQuery(DeleteByQueryRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteByQueryRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Deletes documents matching the provided query. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteByQueryRequest} - * - */ - - public final DeleteByQueryResponse deleteByQuery( - Function> fn) - throws IOException, OpenSearchException { - return deleteByQuery(fn.apply(new DeleteByQueryRequest.Builder()).build()); - } - - // ----- Endpoint: delete_by_query_rethrottle - - /** - * Changes the number of requests per second for a particular Delete By Query - * operation. - * - * - */ - - public DeleteByQueryRethrottleResponse deleteByQueryRethrottle(DeleteByQueryRethrottleRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - DeleteByQueryRethrottleRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Delete By Query - * operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteByQueryRethrottleRequest} - * - */ - - public final DeleteByQueryRethrottleResponse deleteByQueryRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return deleteByQueryRethrottle(fn.apply(new DeleteByQueryRethrottleRequest.Builder()).build()); - } - - // ----- Endpoint: delete_script - - /** - * Deletes a script. - * - * - */ - - public DeleteScriptResponse deleteScript(DeleteScriptRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteScriptRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Deletes a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteScriptRequest} - * - */ - - public final DeleteScriptResponse deleteScript( - Function> fn) - throws IOException, OpenSearchException { - return deleteScript(fn.apply(new DeleteScriptRequest.Builder()).build()); - } - - // ----- Endpoint: exists - - /** - * Returns information about whether a document exists in an index. - * - * - */ - - public BooleanResponse exists(ExistsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ExistsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a document exists in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsRequest} - * - */ - - public final BooleanResponse exists(Function> fn) - throws IOException, OpenSearchException { - return exists(fn.apply(new ExistsRequest.Builder()).build()); - } - - // ----- Endpoint: exists_source - - /** - * Returns information about whether a document source exists in an index. - * - * - */ - - public BooleanResponse existsSource(ExistsSourceRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ExistsSourceRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a document source exists in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsSourceRequest} - * - */ - - public final BooleanResponse existsSource( - Function> fn) - throws IOException, OpenSearchException { - return existsSource(fn.apply(new ExistsSourceRequest.Builder()).build()); - } - - // ----- Endpoint: explain - - /** - * Returns information about why a specific matches (or doesn't match) a query. - * - * - */ - - public ExplainResponse explain(ExplainRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) ExplainRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.explain.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about why a specific matches (or doesn't match) a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExplainRequest} - * - */ - - public final ExplainResponse explain( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return explain(fn.apply(new ExplainRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: field_caps - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * - */ - - public FieldCapsResponse fieldCaps(FieldCapsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) FieldCapsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link FieldCapsRequest} - * - */ - - public final FieldCapsResponse fieldCaps(Function> fn) - throws IOException, OpenSearchException { - return fieldCaps(fn.apply(new FieldCapsRequest.Builder()).build()); - } - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * - */ - - public FieldCapsResponse fieldCaps() throws IOException, OpenSearchException { - return this.transport.performRequest(new FieldCapsRequest.Builder().build(), FieldCapsRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get - - /** - * Returns a document. - * - * - */ - - public GetResponse get(GetRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) GetRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.get.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns a document. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetRequest} - * - */ - - public final GetResponse get(Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return get(fn.apply(new GetRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: get_script - - /** - * Returns a script. - * - * - */ - - public GetScriptResponse getScript(GetScriptRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) GetScriptRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetScriptRequest} - * - */ - - public final GetScriptResponse getScript(Function> fn) - throws IOException, OpenSearchException { - return getScript(fn.apply(new GetScriptRequest.Builder()).build()); - } - - // ----- Endpoint: get_script_context - - /** - * Returns all script contexts. - * - * - */ - public GetScriptContextResponse getScriptContext() throws IOException, OpenSearchException { - return this.transport.performRequest(GetScriptContextRequest._INSTANCE, GetScriptContextRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get_script_languages - - /** - * Returns available script types, languages and contexts - * - * - */ - public GetScriptLanguagesResponse getScriptLanguages() throws IOException, OpenSearchException { - return this.transport.performRequest(GetScriptLanguagesRequest._INSTANCE, GetScriptLanguagesRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get_source - - /** - * Returns the source of a document. - * - * - */ - - public GetSourceResponse getSource(GetSourceRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - GetSourceRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.get_source.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns the source of a document. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetSourceRequest} - * - */ - - public final GetSourceResponse getSource( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return getSource(fn.apply(new GetSourceRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: index - - /** - * Creates or updates a document in an index. - * - * - */ - - public IndexResponse index(IndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, IndexResponse, ErrorResponse> endpoint = - (JsonEndpoint, IndexResponse, ErrorResponse>) IndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates a document in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link IndexRequest} - * - */ - - public final IndexResponse index( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return index(fn.apply(new IndexRequest.Builder()).build()); - } - - // ----- Endpoint: info - - /** - * Returns basic information about the cluster. - * - * - */ - public InfoResponse info() throws IOException, OpenSearchException { - return this.transport.performRequest(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: list_point_in_time - - /** - * List all Point In Time - * - * - */ - - public ListAllPitResponse listAllPit() - throws IOException, OpenSearchException { - return this.transport.performRequest(ListAllPitRequest._INSTANCE, ListAllPitRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: mget - - /** - * Allows to get multiple documents in one request. - * - * - */ - - public MgetResponse mget(MgetRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) MgetRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.mget.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to get multiple documents in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MgetRequest} - * - */ - - public final MgetResponse mget(Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return mget(fn.apply(new MgetRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: msearch - - /** - * Allows to execute several search operations in one request. - * - * - */ - - public MsearchResponse msearch(MsearchRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) MsearchRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.msearch.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to execute several search operations in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MsearchRequest} - * - */ - - public final MsearchResponse msearch( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return msearch(fn.apply(new MsearchRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: msearch_template - - /** - * Allows to execute several search template operations in one request. - * - * - */ - - public MsearchTemplateResponse msearchTemplate(MsearchTemplateRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - MsearchTemplateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.msearch_template.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to execute several search template operations in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MsearchTemplateRequest} - * - */ - - public final MsearchTemplateResponse msearchTemplate( - Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return msearchTemplate(fn.apply(new MsearchTemplateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: mtermvectors - - /** - * Returns multiple termvectors in one request. - * - * - */ - - public MtermvectorsResponse mtermvectors(MtermvectorsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) MtermvectorsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns multiple termvectors in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MtermvectorsRequest} - * - */ - - public final MtermvectorsResponse mtermvectors( - Function> fn) - throws IOException, OpenSearchException { - return mtermvectors(fn.apply(new MtermvectorsRequest.Builder()).build()); - } - - /** - * Returns multiple termvectors in one request. - * - * - */ - - public MtermvectorsResponse mtermvectors() throws IOException, OpenSearchException { - return this.transport.performRequest(new MtermvectorsRequest.Builder().build(), MtermvectorsRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: ping - - /** - * Returns whether the cluster is running. - * - * - */ - public BooleanResponse ping() throws IOException, OpenSearchException { - return this.transport.performRequest(PingRequest._INSTANCE, PingRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: put_script - - /** - * Creates or updates a script. - * - * - */ - - public PutScriptResponse putScript(PutScriptRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) PutScriptRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link PutScriptRequest} - * - */ - - public final PutScriptResponse putScript(Function> fn) - throws IOException, OpenSearchException { - return putScript(fn.apply(new PutScriptRequest.Builder()).build()); - } - - // ----- Endpoint: rank_eval - - /** - * Allows to evaluate the quality of ranked search results over a set of typical - * search queries - * - * - */ - - public RankEvalResponse rankEval(RankEvalRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) RankEvalRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to evaluate the quality of ranked search results over a set of typical - * search queries - * - * @param fn - * a function that initializes a builder to create the - * {@link RankEvalRequest} - * - */ - - public final RankEvalResponse rankEval(Function> fn) - throws IOException, OpenSearchException { - return rankEval(fn.apply(new RankEvalRequest.Builder()).build()); - } - - // ----- Endpoint: reindex - - /** - * Allows to copy documents from one index to another, optionally filtering the - * source documents by a query, changing the destination index settings, or - * fetching the documents from a remote cluster. - * - * - */ - - public ReindexResponse reindex(ReindexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ReindexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to copy documents from one index to another, optionally filtering the - * source documents by a query, changing the destination index settings, or - * fetching the documents from a remote cluster. - * - * @param fn - * a function that initializes a builder to create the - * {@link ReindexRequest} - * - */ - - public final ReindexResponse reindex(Function> fn) - throws IOException, OpenSearchException { - return reindex(fn.apply(new ReindexRequest.Builder()).build()); - } - - /** - * Allows to copy documents from one index to another, optionally filtering the - * source documents by a query, changing the destination index settings, or - * fetching the documents from a remote cluster. - * - * - */ - - public ReindexResponse reindex() throws IOException, OpenSearchException { - return this.transport.performRequest(new ReindexRequest.Builder().build(), ReindexRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: reindex_rethrottle - - /** - * Changes the number of requests per second for a particular Reindex operation. - * - * - */ - - public ReindexRethrottleResponse reindexRethrottle(ReindexRethrottleRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - ReindexRethrottleRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Reindex operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link ReindexRethrottleRequest} - * - */ - - public final ReindexRethrottleResponse reindexRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return reindexRethrottle(fn.apply(new ReindexRethrottleRequest.Builder()).build()); - } - - // ----- Endpoint: render_search_template - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public RenderSearchTemplateResponse renderSearchTemplate(RenderSearchTemplateRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - RenderSearchTemplateRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * @param fn - * a function that initializes a builder to create the - * {@link RenderSearchTemplateRequest} - * - */ - - public final RenderSearchTemplateResponse renderSearchTemplate( - Function> fn) - throws IOException, OpenSearchException { - return renderSearchTemplate(fn.apply(new RenderSearchTemplateRequest.Builder()).build()); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public RenderSearchTemplateResponse renderSearchTemplate() throws IOException, OpenSearchException { - return this.transport.performRequest(new RenderSearchTemplateRequest.Builder().build(), - RenderSearchTemplateRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: scripts_painless_execute - - /** - * Allows an arbitrary script to be executed and a result to be returned - * - * - */ - - public ScriptsPainlessExecuteResponse scriptsPainlessExecute( - ScriptsPainlessExecuteRequest request, Class tResultClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - ScriptsPainlessExecuteRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.scripts_painless_execute.TResult", - getDeserializer(tResultClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows an arbitrary script to be executed and a result to be returned - * - * @param fn - * a function that initializes a builder to create the - * {@link ScriptsPainlessExecuteRequest} - * - */ - - public final ScriptsPainlessExecuteResponse scriptsPainlessExecute( - Function> fn, - Class tResultClass) throws IOException, OpenSearchException { - return scriptsPainlessExecute(fn.apply(new ScriptsPainlessExecuteRequest.Builder()).build(), tResultClass); - } - - // ----- Endpoint: scroll - - /** - * Allows to retrieve a large numbers of results from a single search request. - * - */ - - public ScrollResponse scroll(ScrollRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) ScrollRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.scroll.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to retrieve a large numbers of results from a single search request. - * - * @param fn - * a function that initializes a builder to create the - * {@link ScrollRequest} - */ - - public final ScrollResponse scroll( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return scroll(fn.apply(new ScrollRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: search - - /** - * Returns results matching a query. - * - * - */ - - public SearchResponse search(SearchRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) SearchRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.search.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns results matching a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchRequest} - * - */ - - public final SearchResponse search( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return search(fn.apply(new SearchRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: search_shards - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * - */ - - public SearchShardsResponse searchShards(SearchShardsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) SearchShardsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchShardsRequest} - * - */ - - public final SearchShardsResponse searchShards( - Function> fn) - throws IOException, OpenSearchException { - return searchShards(fn.apply(new SearchShardsRequest.Builder()).build()); - } - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * - */ - - public SearchShardsResponse searchShards() throws IOException, OpenSearchException { - return this.transport.performRequest(new SearchShardsRequest.Builder().build(), SearchShardsRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: search_template - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public SearchTemplateResponse searchTemplate(SearchTemplateRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - SearchTemplateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.search_template.TDocument", - getDeserializer(tDocumentClass)); - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchTemplateRequest} - * - */ - - public final SearchTemplateResponse searchTemplate( - Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: terms_enum - - /** - * The terms enum API can be used to discover terms in the index that begin with - * the provided string. It is designed for low-latency look-ups used in - * auto-complete scenarios. - * - * - */ - - public TermsEnumResponse termsEnum(TermsEnumRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) TermsEnumRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * The terms enum API can be used to discover terms in the index that begin with - * the provided string. It is designed for low-latency look-ups used in - * auto-complete scenarios. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermsEnumRequest} - * - */ - - public final TermsEnumResponse termsEnum(Function> fn) - throws IOException, OpenSearchException { - return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); - } - - // ----- Endpoint: termvectors - - /** - * Returns information and statistics about terms in the fields of a particular - * document. - * - * - */ - - public TermvectorsResponse termvectors(TermvectorsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, TermvectorsResponse, ErrorResponse> endpoint = - (JsonEndpoint, TermvectorsResponse, ErrorResponse>) TermvectorsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information and statistics about terms in the fields of a particular - * document. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermvectorsRequest} - * - */ - - public final TermvectorsResponse termvectors( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return termvectors(fn.apply(new TermvectorsRequest.Builder()).build()); - } - - // ----- Endpoint: update - - /** - * Updates a document with a script or partial document. - * - * - */ - - public UpdateResponse update( - UpdateRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, UpdateResponse, ErrorResponse> endpoint = - (JsonEndpoint, UpdateResponse, ErrorResponse>) UpdateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.update.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Updates a document with a script or partial document. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateRequest} - * - */ - - public final UpdateResponse update( - - Function, - ObjectBuilder>> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return update(fn.apply(new UpdateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: update_by_query - - /** - * Performs an update on every document in the index without changing the - * source, for example to pick up a mapping change. - * - * - */ - - public UpdateByQueryResponse updateByQuery(UpdateByQueryRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - UpdateByQueryRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Performs an update on every document in the index without changing the - * source, for example to pick up a mapping change. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateByQueryRequest} - * - */ - - public final UpdateByQueryResponse updateByQuery( - Function> fn) - throws IOException, OpenSearchException { - return updateByQuery(fn.apply(new UpdateByQueryRequest.Builder()).build()); - } - - // ----- Endpoint: update_by_query_rethrottle - - /** - * Changes the number of requests per second for a particular Update By Query - * operation. - * - * - */ - - public UpdateByQueryRethrottleResponse updateByQueryRethrottle(UpdateByQueryRethrottleRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - UpdateByQueryRethrottleRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Update By Query - * operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateByQueryRethrottleRequest} - * - */ - - public final UpdateByQueryRethrottleResponse updateByQueryRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return updateByQueryRethrottle(fn.apply(new UpdateByQueryRethrottleRequest.Builder()).build()); - } + public OpenSearchClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public OpenSearchClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchClient(this.transport, transportOptions); + } + + // ----- Child clients + + public OpenSearchCatClient cat() { + return new OpenSearchCatClient(this.transport, this.transportOptions); + } + + 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); + } + + public OpenSearchIndicesClient indices() { + return new OpenSearchIndicesClient(this.transport, this.transportOptions); + } + + public OpenSearchIngestClient ingest() { + return new OpenSearchIngestClient(this.transport, this.transportOptions); + } + + public OpenSearchNodesClient nodes() { + return new OpenSearchNodesClient(this.transport, this.transportOptions); + } + + public OpenSearchShutdownClient shutdown() { + return new OpenSearchShutdownClient(this.transport, this.transportOptions); + } + + public OpenSearchSnapshotClient snapshot() { + return new OpenSearchSnapshotClient(this.transport, this.transportOptions); + } + + public OpenSearchTasksClient tasks() { + return new OpenSearchTasksClient(this.transport, this.transportOptions); + } + + // ----- Endpoint: bulk + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * + */ + + public BulkResponse bulk(BulkRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + BulkRequest, + BulkResponse, + ErrorResponse>) BulkRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * @param fn + * a function that initializes a builder to create the + * {@link BulkRequest} + * + */ + + public final BulkResponse bulk(Function> fn) throws IOException, OpenSearchException { + return bulk(fn.apply(new BulkRequest.Builder()).build()); + } + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * + */ + + public BulkResponse bulk() throws IOException, OpenSearchException { + return this.transport.performRequest(new BulkRequest.Builder().build(), BulkRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: clear_scroll + + /** + * Explicitly clears the search context for a scroll. + * + * + */ + + public ClearScrollResponse clearScroll(ClearScrollRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ClearScrollRequest, + ClearScrollResponse, + ErrorResponse>) ClearScrollRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Explicitly clears the search context for a scroll. + * + * @param fn + * a function that initializes a builder to create the + * {@link ClearScrollRequest} + * + */ + + public final ClearScrollResponse clearScroll(Function> fn) + throws IOException, OpenSearchException { + return clearScroll(fn.apply(new ClearScrollRequest.Builder()).build()); + } + + /** + * Explicitly clears the search context for a scroll. + * + * + */ + + public ClearScrollResponse clearScroll() throws IOException, OpenSearchException { + return this.transport.performRequest(new ClearScrollRequest.Builder().build(), ClearScrollRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: count + + /** + * Returns number of documents matching a query. + * + * + */ + + public CountResponse count(CountRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + CountRequest, + CountResponse, + ErrorResponse>) CountRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns number of documents matching a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link CountRequest} + * + */ + + public final CountResponse count(Function> fn) throws IOException, + OpenSearchException { + return count(fn.apply(new CountRequest.Builder()).build()); + } + + /** + * Returns number of documents matching a query. + * + * + */ + + public CountResponse count() throws IOException, OpenSearchException { + return this.transport.performRequest(new CountRequest.Builder().build(), CountRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: create + + /** + * Creates a new document in the index. + *

+ * Returns a 409 response when a document with a same ID already exists in the + * index. + * + * + */ + + public CreateResponse create(CreateRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, CreateResponse, ErrorResponse> endpoint = (JsonEndpoint< + CreateRequest, + CreateResponse, + ErrorResponse>) CreateRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Creates a new document in the index. + *

+ * Returns a 409 response when a document with a same ID already exists in the + * index. + * + * @param fn + * a function that initializes a builder to create the + * {@link CreateRequest} + * + */ + + public final CreateResponse create(Function, ObjectBuilder>> fn) + throws IOException, OpenSearchException { + return create(fn.apply(new CreateRequest.Builder()).build()); + } + + // ----- Endpoint: create_point_in_time + + /** + * Provides low-level information about the disk utilization of a PIT by + * describing its Lucene segments. + * + * + */ + + public CreatePitResponse createPit(CreatePitRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + CreatePitRequest, + CreatePitResponse, + ErrorResponse>) CreatePitRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Provides low-level information about the disk utilization of a PIT by + * describing its Lucene segments. + * + * @param fn + * a function that initializes a builder to create the + * {@link CreatePitRequest} + * + */ + + public final CreatePitResponse createPit(Function> fn) throws IOException, + OpenSearchException { + return createPit(fn.apply(new CreatePitRequest.Builder()).build()); + } + + // ----- Endpoint: delete + + /** + * Removes a document from the index. + * + * + */ + + public DeleteResponse delete(DeleteRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteRequest, + DeleteResponse, + ErrorResponse>) DeleteRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Removes a document from the index. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteRequest} + * + */ + + public final DeleteResponse delete(Function> fn) throws IOException, + OpenSearchException { + return delete(fn.apply(new DeleteRequest.Builder()).build()); + } + + // ----- Endpoint: delete_point_in_time + + /** + * Delete Point In Time + * + * + */ + + public DeletePitResponse deletePit(DeletePitRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeletePitRequest, + DeletePitResponse, + ErrorResponse>) DeletePitRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Delete Point In Time + * + * @param fn + * a function that initializes a builder to create the + * {@link DeletePitRequest} + * + */ + + public final DeletePitResponse deletePit(Function> fn) throws IOException, + OpenSearchException { + return deletePit(fn.apply(new DeletePitRequest.Builder()).build()); + } + + // ----- Endpoint: delete_by_query + + /** + * Deletes documents matching the provided query. + * + * + */ + + public DeleteByQueryResponse deleteByQuery(DeleteByQueryRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteByQueryRequest, + DeleteByQueryResponse, + ErrorResponse>) DeleteByQueryRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Deletes documents matching the provided query. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteByQueryRequest} + * + */ + + public final DeleteByQueryResponse deleteByQuery(Function> fn) + throws IOException, OpenSearchException { + return deleteByQuery(fn.apply(new DeleteByQueryRequest.Builder()).build()); + } + + // ----- Endpoint: delete_by_query_rethrottle + + /** + * Changes the number of requests per second for a particular Delete By Query + * operation. + * + * + */ + + public DeleteByQueryRethrottleResponse deleteByQueryRethrottle(DeleteByQueryRethrottleRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteByQueryRethrottleRequest, + DeleteByQueryRethrottleResponse, + ErrorResponse>) DeleteByQueryRethrottleRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Delete By Query + * operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteByQueryRethrottleRequest} + * + */ + + public final DeleteByQueryRethrottleResponse deleteByQueryRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return deleteByQueryRethrottle(fn.apply(new DeleteByQueryRethrottleRequest.Builder()).build()); + } + + // ----- Endpoint: delete_script + + /** + * Deletes a script. + * + * + */ + + public DeleteScriptResponse deleteScript(DeleteScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteScriptRequest, + DeleteScriptResponse, + ErrorResponse>) DeleteScriptRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Deletes a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteScriptRequest} + * + */ + + public final DeleteScriptResponse deleteScript(Function> fn) + throws IOException, OpenSearchException { + return deleteScript(fn.apply(new DeleteScriptRequest.Builder()).build()); + } + + // ----- Endpoint: exists + + /** + * Returns information about whether a document exists in an index. + * + * + */ + + public BooleanResponse exists(ExistsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ExistsRequest, + BooleanResponse, + ErrorResponse>) ExistsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information about whether a document exists in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExistsRequest} + * + */ + + public final BooleanResponse exists(Function> fn) throws IOException, + OpenSearchException { + return exists(fn.apply(new ExistsRequest.Builder()).build()); + } + + // ----- Endpoint: exists_source + + /** + * Returns information about whether a document source exists in an index. + * + * + */ + + public BooleanResponse existsSource(ExistsSourceRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ExistsSourceRequest, + BooleanResponse, + ErrorResponse>) ExistsSourceRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information about whether a document source exists in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExistsSourceRequest} + * + */ + + public final BooleanResponse existsSource(Function> fn) + throws IOException, OpenSearchException { + return existsSource(fn.apply(new ExistsSourceRequest.Builder()).build()); + } + + // ----- Endpoint: explain + + /** + * Returns information about why a specific matches (or doesn't match) a query. + * + * + */ + + public ExplainResponse explain(ExplainRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ExplainRequest, + ExplainResponse, + ErrorResponse>) ExplainRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.explain.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information about why a specific matches (or doesn't match) a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExplainRequest} + * + */ + + public final ExplainResponse explain( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return explain(fn.apply(new ExplainRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: field_caps + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * + */ + + public FieldCapsResponse fieldCaps(FieldCapsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + FieldCapsRequest, + FieldCapsResponse, + ErrorResponse>) FieldCapsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * @param fn + * a function that initializes a builder to create the + * {@link FieldCapsRequest} + * + */ + + public final FieldCapsResponse fieldCaps(Function> fn) throws IOException, + OpenSearchException { + return fieldCaps(fn.apply(new FieldCapsRequest.Builder()).build()); + } + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * + */ + + public FieldCapsResponse fieldCaps() throws IOException, OpenSearchException { + return this.transport.performRequest(new FieldCapsRequest.Builder().build(), FieldCapsRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: get + + /** + * Returns a document. + * + * + */ + + public GetResponse get(GetRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + GetRequest, + GetResponse, + ErrorResponse>) GetRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.get.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns a document. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRequest} + * + */ + + public final GetResponse get( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return get(fn.apply(new GetRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: get_script + + /** + * Returns a script. + * + * + */ + + public GetScriptResponse getScript(GetScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + GetScriptRequest, + GetScriptResponse, + ErrorResponse>) GetScriptRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetScriptRequest} + * + */ + + public final GetScriptResponse getScript(Function> fn) throws IOException, + OpenSearchException { + return getScript(fn.apply(new GetScriptRequest.Builder()).build()); + } + + // ----- Endpoint: get_script_context + + /** + * Returns all script contexts. + * + * + */ + public GetScriptContextResponse getScriptContext() throws IOException, OpenSearchException { + return this.transport.performRequest(GetScriptContextRequest._INSTANCE, GetScriptContextRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: get_script_languages + + /** + * Returns available script types, languages and contexts + * + * + */ + public GetScriptLanguagesResponse getScriptLanguages() throws IOException, OpenSearchException { + return this.transport.performRequest( + GetScriptLanguagesRequest._INSTANCE, + GetScriptLanguagesRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: get_source + + /** + * Returns the source of a document. + * + * + */ + + public GetSourceResponse getSource(GetSourceRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + GetSourceRequest, + GetSourceResponse, + ErrorResponse>) GetSourceRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.get_source.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns the source of a document. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetSourceRequest} + * + */ + + public final GetSourceResponse getSource( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return getSource(fn.apply(new GetSourceRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: index + + /** + * Creates or updates a document in an index. + * + * + */ + + public IndexResponse index(IndexRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, IndexResponse, ErrorResponse> endpoint = (JsonEndpoint< + IndexRequest, + IndexResponse, + ErrorResponse>) IndexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Creates or updates a document in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link IndexRequest} + * + */ + + public final IndexResponse index(Function, ObjectBuilder>> fn) + throws IOException, OpenSearchException { + return index(fn.apply(new IndexRequest.Builder()).build()); + } + + // ----- Endpoint: info + + /** + * Returns basic information about the cluster. + * + * + */ + public InfoResponse info() throws IOException, OpenSearchException { + return this.transport.performRequest(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: list_point_in_time + + /** + * List all Point In Time + * + * + */ + + public ListAllPitResponse listAllPit() throws IOException, OpenSearchException { + return this.transport.performRequest(ListAllPitRequest._INSTANCE, ListAllPitRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: mget + + /** + * Allows to get multiple documents in one request. + * + * + */ + + public MgetResponse mget(MgetRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MgetRequest, + MgetResponse, + ErrorResponse>) MgetRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.mget.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to get multiple documents in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MgetRequest} + * + */ + + public final MgetResponse mget( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return mget(fn.apply(new MgetRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: msearch + + /** + * Allows to execute several search operations in one request. + * + * + */ + + public MsearchResponse msearch(MsearchRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MsearchRequest, + MsearchResponse, + ErrorResponse>) MsearchRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.msearch.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to execute several search operations in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MsearchRequest} + * + */ + + public final MsearchResponse msearch( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return msearch(fn.apply(new MsearchRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: msearch_template + + /** + * Allows to execute several search template operations in one request. + * + * + */ + + public MsearchTemplateResponse msearchTemplate(MsearchTemplateRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MsearchTemplateRequest, + MsearchTemplateResponse, + ErrorResponse>) MsearchTemplateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.msearch_template.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to execute several search template operations in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MsearchTemplateRequest} + * + */ + + public final MsearchTemplateResponse msearchTemplate( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return msearchTemplate(fn.apply(new MsearchTemplateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: mtermvectors + + /** + * Returns multiple termvectors in one request. + * + * + */ + + public MtermvectorsResponse mtermvectors(MtermvectorsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + MtermvectorsRequest, + MtermvectorsResponse, + ErrorResponse>) MtermvectorsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns multiple termvectors in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MtermvectorsRequest} + * + */ + + public final MtermvectorsResponse mtermvectors(Function> fn) + throws IOException, OpenSearchException { + return mtermvectors(fn.apply(new MtermvectorsRequest.Builder()).build()); + } + + /** + * Returns multiple termvectors in one request. + * + * + */ + + public MtermvectorsResponse mtermvectors() throws IOException, OpenSearchException { + return this.transport.performRequest( + new MtermvectorsRequest.Builder().build(), + MtermvectorsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: ping + + /** + * Returns whether the cluster is running. + * + * + */ + public BooleanResponse ping() throws IOException, OpenSearchException { + return this.transport.performRequest(PingRequest._INSTANCE, PingRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: put_script + + /** + * Creates or updates a script. + * + * + */ + + public PutScriptResponse putScript(PutScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + PutScriptRequest, + PutScriptResponse, + ErrorResponse>) PutScriptRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Creates or updates a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link PutScriptRequest} + * + */ + + public final PutScriptResponse putScript(Function> fn) throws IOException, + OpenSearchException { + return putScript(fn.apply(new PutScriptRequest.Builder()).build()); + } + + // ----- Endpoint: rank_eval + + /** + * Allows to evaluate the quality of ranked search results over a set of typical + * search queries + * + * + */ + + public RankEvalResponse rankEval(RankEvalRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + RankEvalRequest, + RankEvalResponse, + ErrorResponse>) RankEvalRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to evaluate the quality of ranked search results over a set of typical + * search queries + * + * @param fn + * a function that initializes a builder to create the + * {@link RankEvalRequest} + * + */ + + public final RankEvalResponse rankEval(Function> fn) throws IOException, + OpenSearchException { + return rankEval(fn.apply(new RankEvalRequest.Builder()).build()); + } + + // ----- Endpoint: reindex + + /** + * Allows to copy documents from one index to another, optionally filtering the + * source documents by a query, changing the destination index settings, or + * fetching the documents from a remote cluster. + * + * + */ + + public ReindexResponse reindex(ReindexRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ReindexRequest, + ReindexResponse, + ErrorResponse>) ReindexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to copy documents from one index to another, optionally filtering the + * source documents by a query, changing the destination index settings, or + * fetching the documents from a remote cluster. + * + * @param fn + * a function that initializes a builder to create the + * {@link ReindexRequest} + * + */ + + public final ReindexResponse reindex(Function> fn) throws IOException, + OpenSearchException { + return reindex(fn.apply(new ReindexRequest.Builder()).build()); + } + + /** + * Allows to copy documents from one index to another, optionally filtering the + * source documents by a query, changing the destination index settings, or + * fetching the documents from a remote cluster. + * + * + */ + + public ReindexResponse reindex() throws IOException, OpenSearchException { + return this.transport.performRequest(new ReindexRequest.Builder().build(), ReindexRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: reindex_rethrottle + + /** + * Changes the number of requests per second for a particular Reindex operation. + * + * + */ + + public ReindexRethrottleResponse reindexRethrottle(ReindexRethrottleRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ReindexRethrottleRequest, + ReindexRethrottleResponse, + ErrorResponse>) ReindexRethrottleRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Reindex operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link ReindexRethrottleRequest} + * + */ + + public final ReindexRethrottleResponse reindexRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return reindexRethrottle(fn.apply(new ReindexRethrottleRequest.Builder()).build()); + } + + // ----- Endpoint: render_search_template + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public RenderSearchTemplateResponse renderSearchTemplate(RenderSearchTemplateRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + RenderSearchTemplateRequest, + RenderSearchTemplateResponse, + ErrorResponse>) RenderSearchTemplateRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * @param fn + * a function that initializes a builder to create the + * {@link RenderSearchTemplateRequest} + * + */ + + public final RenderSearchTemplateResponse renderSearchTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return renderSearchTemplate(fn.apply(new RenderSearchTemplateRequest.Builder()).build()); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public RenderSearchTemplateResponse renderSearchTemplate() throws IOException, OpenSearchException { + return this.transport.performRequest( + new RenderSearchTemplateRequest.Builder().build(), + RenderSearchTemplateRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: scripts_painless_execute + + /** + * Allows an arbitrary script to be executed and a result to be returned + * + * + */ + + public ScriptsPainlessExecuteResponse scriptsPainlessExecute( + ScriptsPainlessExecuteRequest request, + Class tResultClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ScriptsPainlessExecuteRequest, + ScriptsPainlessExecuteResponse, + ErrorResponse>) ScriptsPainlessExecuteRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.scripts_painless_execute.TResult", + getDeserializer(tResultClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows an arbitrary script to be executed and a result to be returned + * + * @param fn + * a function that initializes a builder to create the + * {@link ScriptsPainlessExecuteRequest} + * + */ + + public final ScriptsPainlessExecuteResponse scriptsPainlessExecute( + Function> fn, + Class tResultClass + ) throws IOException, OpenSearchException { + return scriptsPainlessExecute(fn.apply(new ScriptsPainlessExecuteRequest.Builder()).build(), tResultClass); + } + + // ----- Endpoint: scroll + + /** + * Allows to retrieve a large numbers of results from a single search request. + * + */ + + public ScrollResponse scroll(ScrollRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ScrollRequest, + ScrollResponse, + ErrorResponse>) ScrollRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.scroll.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to retrieve a large numbers of results from a single search request. + * + * @param fn + * a function that initializes a builder to create the + * {@link ScrollRequest} + */ + + public final ScrollResponse scroll( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return scroll(fn.apply(new ScrollRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: search + + /** + * Returns results matching a query. + * + * + */ + + public SearchResponse search(SearchRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + SearchRequest, + SearchResponse, + ErrorResponse>) SearchRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.search.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns results matching a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchRequest} + * + */ + + public final SearchResponse search( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return search(fn.apply(new SearchRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: search_shards + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * + */ + + public SearchShardsResponse searchShards(SearchShardsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + SearchShardsRequest, + SearchShardsResponse, + ErrorResponse>) SearchShardsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchShardsRequest} + * + */ + + public final SearchShardsResponse searchShards(Function> fn) + throws IOException, OpenSearchException { + return searchShards(fn.apply(new SearchShardsRequest.Builder()).build()); + } + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * + */ + + public SearchShardsResponse searchShards() throws IOException, OpenSearchException { + return this.transport.performRequest( + new SearchShardsRequest.Builder().build(), + SearchShardsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: search_template + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public SearchTemplateResponse searchTemplate(SearchTemplateRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + SearchTemplateRequest, + SearchTemplateResponse, + ErrorResponse>) SearchTemplateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.search_template.TDocument", + getDeserializer(tDocumentClass) + ); + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchTemplateRequest} + * + */ + + public final SearchTemplateResponse searchTemplate( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: terms_enum + + /** + * The terms enum API can be used to discover terms in the index that begin with + * the provided string. It is designed for low-latency look-ups used in + * auto-complete scenarios. + * + * + */ + + public TermsEnumResponse termsEnum(TermsEnumRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + TermsEnumRequest, + TermsEnumResponse, + ErrorResponse>) TermsEnumRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * The terms enum API can be used to discover terms in the index that begin with + * the provided string. It is designed for low-latency look-ups used in + * auto-complete scenarios. + * + * @param fn + * a function that initializes a builder to create the + * {@link TermsEnumRequest} + * + */ + + public final TermsEnumResponse termsEnum(Function> fn) throws IOException, + OpenSearchException { + return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); + } + + // ----- Endpoint: termvectors + + /** + * Returns information and statistics about terms in the fields of a particular + * document. + * + * + */ + + public TermvectorsResponse termvectors(TermvectorsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, TermvectorsResponse, ErrorResponse> endpoint = (JsonEndpoint< + TermvectorsRequest, + TermvectorsResponse, + ErrorResponse>) TermvectorsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information and statistics about terms in the fields of a particular + * document. + * + * @param fn + * a function that initializes a builder to create the + * {@link TermvectorsRequest} + * + */ + + public final TermvectorsResponse termvectors( + Function, ObjectBuilder>> fn + ) throws IOException, OpenSearchException { + return termvectors(fn.apply(new TermvectorsRequest.Builder()).build()); + } + + // ----- Endpoint: update + + /** + * Updates a document with a script or partial document. + * + * + */ + + public UpdateResponse update( + UpdateRequest request, + Class tDocumentClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, UpdateResponse, ErrorResponse> endpoint = (JsonEndpoint< + UpdateRequest, + UpdateResponse, + ErrorResponse>) UpdateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.update.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Updates a document with a script or partial document. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateRequest} + * + */ + + public final UpdateResponse update( + + Function, ObjectBuilder>> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return update(fn.apply(new UpdateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: update_by_query + + /** + * Performs an update on every document in the index without changing the + * source, for example to pick up a mapping change. + * + * + */ + + public UpdateByQueryResponse updateByQuery(UpdateByQueryRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + UpdateByQueryRequest, + UpdateByQueryResponse, + ErrorResponse>) UpdateByQueryRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Performs an update on every document in the index without changing the + * source, for example to pick up a mapping change. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateByQueryRequest} + * + */ + + public final UpdateByQueryResponse updateByQuery(Function> fn) + throws IOException, OpenSearchException { + return updateByQuery(fn.apply(new UpdateByQueryRequest.Builder()).build()); + } + + // ----- Endpoint: update_by_query_rethrottle + + /** + * Changes the number of requests per second for a particular Update By Query + * operation. + * + * + */ + + public UpdateByQueryRethrottleResponse updateByQueryRethrottle(UpdateByQueryRethrottleRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + UpdateByQueryRethrottleRequest, + UpdateByQueryRethrottleResponse, + ErrorResponse>) UpdateByQueryRethrottleRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Update By Query + * operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateByQueryRethrottleRequest} + * + */ + + public final UpdateByQueryRethrottleResponse updateByQueryRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return updateByQueryRethrottle(fn.apply(new UpdateByQueryRethrottleRequest.Builder()).build()); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/watcher/HourAndMinute.java b/java-client/src/main/java/org/opensearch/client/opensearch/watcher/HourAndMinute.java index f306519849..7df892369a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/watcher/HourAndMinute.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/watcher/HourAndMinute.java @@ -32,6 +32,9 @@ package org.opensearch.client.opensearch.watcher; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -41,157 +44,155 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.function.Function; // typedef: watcher._types.HourAndMinute - @JsonpDeserializable public class HourAndMinute implements JsonpSerializable { - private final List hour; - - private final List minute; - - // --------------------------------------------------------------------------------------------- - - private HourAndMinute(Builder builder) { - - this.hour = ApiTypeHelper.unmodifiableRequired(builder.hour, this, "hour"); - this.minute = ApiTypeHelper.unmodifiableRequired(builder.minute, this, "minute"); - - } - - public static HourAndMinute of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code hour} - */ - public final List hour() { - return this.hour; - } - - /** - * Required - API name: {@code minute} - */ - public final List minute() { - return this.minute; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.hour)) { - generator.writeKey("hour"); - generator.writeStartArray(); - for (Integer item0 : this.hour) { - generator.write(item0); - - } - generator.writeEnd(); - - } - if (ApiTypeHelper.isDefined(this.minute)) { - generator.writeKey("minute"); - generator.writeStartArray(); - for (Integer item0 : this.minute) { - generator.write(item0); - - } - generator.writeEnd(); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link HourAndMinute}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private List hour; - - private List minute; - - /** - * Required - API name: {@code hour} - *

- * Adds all elements of list to hour. - */ - public final Builder hour(List list) { - this.hour = _listAddAll(this.hour, list); - return this; - } - - /** - * Required - API name: {@code hour} - *

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

- * Adds all elements of list to minute. - */ - public final Builder minute(List list) { - this.minute = _listAddAll(this.minute, list); - return this; - } - - /** - * Required - API name: {@code minute} - *

- * Adds one or more values to minute. - */ - public final Builder minute(Integer value, Integer... values) { - this.minute = _listAdd(this.minute, value, values); - return this; - } - - /** - * Builds a {@link HourAndMinute}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public HourAndMinute build() { - _checkSingleUse(); - - return new HourAndMinute(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link HourAndMinute} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - HourAndMinute::setupHourAndMinuteDeserializer); - - protected static void setupHourAndMinuteDeserializer(ObjectDeserializer op) { - - op.add(Builder::hour, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.integerDeserializer()), "hour"); - op.add(Builder::minute, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.integerDeserializer()), "minute"); - - } + private final List hour; + + private final List minute; + + // --------------------------------------------------------------------------------------------- + + private HourAndMinute(Builder builder) { + + this.hour = ApiTypeHelper.unmodifiableRequired(builder.hour, this, "hour"); + this.minute = ApiTypeHelper.unmodifiableRequired(builder.minute, this, "minute"); + + } + + public static HourAndMinute of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code hour} + */ + public final List hour() { + return this.hour; + } + + /** + * Required - API name: {@code minute} + */ + public final List minute() { + return this.minute; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (ApiTypeHelper.isDefined(this.hour)) { + generator.writeKey("hour"); + generator.writeStartArray(); + for (Integer item0 : this.hour) { + generator.write(item0); + + } + generator.writeEnd(); + + } + if (ApiTypeHelper.isDefined(this.minute)) { + generator.writeKey("minute"); + generator.writeStartArray(); + for (Integer item0 : this.minute) { + generator.write(item0); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link HourAndMinute}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private List hour; + + private List minute; + + /** + * Required - API name: {@code hour} + *

+ * Adds all elements of list to hour. + */ + public final Builder hour(List list) { + this.hour = _listAddAll(this.hour, list); + return this; + } + + /** + * Required - API name: {@code hour} + *

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

+ * Adds all elements of list to minute. + */ + public final Builder minute(List list) { + this.minute = _listAddAll(this.minute, list); + return this; + } + + /** + * Required - API name: {@code minute} + *

+ * Adds one or more values to minute. + */ + public final Builder minute(Integer value, Integer... values) { + this.minute = _listAdd(this.minute, value, values); + return this; + } + + /** + * Builds a {@link HourAndMinute}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public HourAndMinute build() { + _checkSingleUse(); + + return new HourAndMinute(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link HourAndMinute} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + HourAndMinute::setupHourAndMinuteDeserializer + ); + + protected static void setupHourAndMinuteDeserializer(ObjectDeserializer op) { + + op.add(Builder::hour, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.integerDeserializer()), "hour"); + op.add(Builder::minute, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.integerDeserializer()), "minute"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/watcher/TimeOfDay.java b/java-client/src/main/java/org/opensearch/client/opensearch/watcher/TimeOfDay.java index f88a09a7a9..c2c299a511 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/watcher/TimeOfDay.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/watcher/TimeOfDay.java @@ -32,6 +32,8 @@ package org.opensearch.client.opensearch.watcher; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -42,133 +44,129 @@ import org.opensearch.client.util.ObjectBuilderBase; import org.opensearch.client.util.TaggedUnion; import org.opensearch.client.util.TaggedUnionUtils; -import jakarta.json.stream.JsonGenerator; -import java.lang.Object; -import java.lang.String; -import java.util.function.Function; // typedef: watcher._types.TimeOfDay - @JsonpDeserializable public class TimeOfDay implements TaggedUnion, JsonpSerializable { - public enum Kind { - Text, HourMinute - - } - - private final Kind _kind; - private final Object _value; - - @Override - public final Kind _kind() { - return _kind; - } - - @Override - public final Object _get() { - return _value; - } - - private TimeOfDay(Kind kind, Object value) { - this._kind = kind; - this._value = value; - } - - private TimeOfDay(Builder builder) { - - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); - this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - - } - - public static TimeOfDay of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Is this variant instance of kind {@code text}? - */ - public boolean isText() { - return _kind == Kind.Text; - } - - /** - * Get the {@code text} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code text} kind. - */ - public String text() { - return TaggedUnionUtils.get(this, Kind.Text); - } - - /** - * Is this variant instance of kind {@code hour_minute}? - */ - public boolean isHourMinute() { - return _kind == Kind.HourMinute; - } - - /** - * Get the {@code hour_minute} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code hour_minute} kind. - */ - public HourAndMinute hourMinute() { - return TaggedUnionUtils.get(this, Kind.HourMinute); - } - - @Override - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - if (_value instanceof JsonpSerializable) { - ((JsonpSerializable) _value).serialize(generator, mapper); - } else { - switch (_kind) { - case Text : - generator.write(((String) this._value)); - - break; - } - } - - } - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Kind _kind; - private Object _value; - - public ObjectBuilder text(String v) { - this._kind = Kind.Text; - this._value = v; - return this; - } - - public ObjectBuilder hourMinute(HourAndMinute v) { - this._kind = Kind.HourMinute; - this._value = v; - return this; - } - - public ObjectBuilder hourMinute(Function> fn) { - return this.hourMinute(fn.apply(new HourAndMinute.Builder()).build()); - } - - public TimeOfDay build() { - _checkSingleUse(); - return new TimeOfDay(this); - } - - } - - private static JsonpDeserializer buildTimeOfDayDeserializer() { - return new UnionDeserializer.Builder(TimeOfDay::new, false) - .addMember(Kind.Text, JsonpDeserializer.stringDeserializer()) - .addMember(Kind.HourMinute, HourAndMinute._DESERIALIZER).build(); - } - - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer - .lazy(TimeOfDay::buildTimeOfDayDeserializer); + public enum Kind { + Text, + HourMinute + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + private TimeOfDay(Kind kind, Object value) { + this._kind = kind; + this._value = value; + } + + private TimeOfDay(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static TimeOfDay of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code text}? + */ + public boolean isText() { + return _kind == Kind.Text; + } + + /** + * Get the {@code text} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code text} kind. + */ + public String text() { + return TaggedUnionUtils.get(this, Kind.Text); + } + + /** + * Is this variant instance of kind {@code hour_minute}? + */ + public boolean isHourMinute() { + return _kind == Kind.HourMinute; + } + + /** + * Get the {@code hour_minute} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code hour_minute} kind. + */ + public HourAndMinute hourMinute() { + return TaggedUnionUtils.get(this, Kind.HourMinute); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } else { + switch (_kind) { + case Text: + generator.write(((String) this._value)); + + break; + } + } + + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder text(String v) { + this._kind = Kind.Text; + this._value = v; + return this; + } + + public ObjectBuilder hourMinute(HourAndMinute v) { + this._kind = Kind.HourMinute; + this._value = v; + return this; + } + + public ObjectBuilder hourMinute(Function> fn) { + return this.hourMinute(fn.apply(new HourAndMinute.Builder()).build()); + } + + public TimeOfDay build() { + _checkSingleUse(); + return new TimeOfDay(this); + } + + } + + private static JsonpDeserializer buildTimeOfDayDeserializer() { + return new UnionDeserializer.Builder(TimeOfDay::new, false).addMember( + Kind.Text, + JsonpDeserializer.stringDeserializer() + ).addMember(Kind.HourMinute, HourAndMinute._DESERIALIZER).build(); + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.lazy(TimeOfDay::buildTimeOfDayDeserializer); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/watcher/TimeOfDayBuilders.java b/java-client/src/main/java/org/opensearch/client/opensearch/watcher/TimeOfDayBuilders.java index ffb505a167..ae2ba43b04 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/watcher/TimeOfDayBuilders.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/watcher/TimeOfDayBuilders.java @@ -37,18 +37,17 @@ *

* Variants text are not available here as they don't have a * dedicated class. Use {@link TimeOfDay}'s builder for these. - * + * */ public class TimeOfDayBuilders { - private TimeOfDayBuilders() { - } + private TimeOfDayBuilders() {} - /** - * Creates a builder for the {@link HourAndMinute hour_minute} {@code TimeOfDay} - * variant. - */ - public static HourAndMinute.Builder hourMinute() { - return new HourAndMinute.Builder(); - } + /** + * Creates a builder for the {@link HourAndMinute hour_minute} {@code TimeOfDay} + * variant. + */ + public static HourAndMinute.Builder hourMinute() { + return new HourAndMinute.Builder(); + } }