Skip to content

Commit

Permalink
[codegen] Add Type in addition to Class to map types with generic par…
Browse files Browse the repository at this point in the history
…ameters
  • Loading branch information
swallez committed Nov 4, 2022
1 parent 1721de8 commit 1d55a13
Show file tree
Hide file tree
Showing 12 changed files with 1,333 additions and 0 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import co.elastic.clients.transport.TransportOptions;
import co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr;
import co.elastic.clients.util.ObjectBuilder;
import java.lang.reflect.Type;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -131,6 +132,42 @@ public final <TDocument> CompletableFuture<GetAsyncSearchResponse<TDocument>> ge
return get(fn.apply(new GetAsyncSearchRequest.Builder()).build(), tDocumentClass);
}

/**
* Retrieves the results of a previously submitted async search request given
* its ID.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public <TDocument> CompletableFuture<GetAsyncSearchResponse<TDocument>> get(GetAsyncSearchRequest request,
Type tDocumentType) {
@SuppressWarnings("unchecked")
JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse>) GetAsyncSearchRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:async_search.get.TDocument", getDeserializer(tDocumentType));

return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}

/**
* Retrieves the results of a previously submitted async search request given
* its ID.
*
* @param fn
* a function that initializes a builder to create the
* {@link GetAsyncSearchRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public final <TDocument> CompletableFuture<GetAsyncSearchResponse<TDocument>> get(
Function<GetAsyncSearchRequest.Builder, ObjectBuilder<GetAsyncSearchRequest>> fn, Type tDocumentType) {
return get(fn.apply(new GetAsyncSearchRequest.Builder()).build(), tDocumentType);
}

// ----- Endpoint: async_search.status

/**
Expand Down Expand Up @@ -170,6 +207,43 @@ public final <TDocument> CompletableFuture<AsyncSearchStatusResponse<TDocument>>
return status(fn.apply(new AsyncSearchStatusRequest.Builder()).build(), tDocumentClass);
}

/**
* Retrieves the status of a previously submitted async search request given its
* ID.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public <TDocument> CompletableFuture<AsyncSearchStatusResponse<TDocument>> status(AsyncSearchStatusRequest request,
Type tDocumentType) {
@SuppressWarnings("unchecked")
JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse>) AsyncSearchStatusRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:async_search.status.TDocument", getDeserializer(tDocumentType));

return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}

/**
* Retrieves the status of a previously submitted async search request given its
* ID.
*
* @param fn
* a function that initializes a builder to create the
* {@link AsyncSearchStatusRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public final <TDocument> CompletableFuture<AsyncSearchStatusResponse<TDocument>> status(
Function<AsyncSearchStatusRequest.Builder, ObjectBuilder<AsyncSearchStatusRequest>> fn,
Type tDocumentType) {
return status(fn.apply(new AsyncSearchStatusRequest.Builder()).build(), tDocumentType);
}

// ----- Endpoint: async_search.submit

/**
Expand Down Expand Up @@ -206,4 +280,37 @@ public final <TDocument> CompletableFuture<SubmitResponse<TDocument>> submit(
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentClass);
}

/**
* Executes a search request asynchronously.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public <TDocument> CompletableFuture<SubmitResponse<TDocument>> submit(SubmitRequest request, Type tDocumentType) {
@SuppressWarnings("unchecked")
JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse>) SubmitRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:async_search.submit.TDocument", getDeserializer(tDocumentType));

return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}

/**
* Executes a search request asynchronously.
*
* @param fn
* a function that initializes a builder to create the
* {@link SubmitRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public final <TDocument> CompletableFuture<SubmitResponse<TDocument>> submit(
Function<SubmitRequest.Builder, ObjectBuilder<SubmitRequest>> fn, Type tDocumentType) {
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr;
import co.elastic.clients.util.ObjectBuilder;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.function.Function;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -132,6 +133,43 @@ public final <TDocument> GetAsyncSearchResponse<TDocument> get(
return get(fn.apply(new GetAsyncSearchRequest.Builder()).build(), tDocumentClass);
}

/**
* Retrieves the results of a previously submitted async search request given
* its ID.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public <TDocument> GetAsyncSearchResponse<TDocument> get(GetAsyncSearchRequest request, Type tDocumentType)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse>) GetAsyncSearchRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:async_search.get.TDocument", getDeserializer(tDocumentType));

return this.transport.performRequest(request, endpoint, this.transportOptions);
}

/**
* Retrieves the results of a previously submitted async search request given
* its ID.
*
* @param fn
* a function that initializes a builder to create the
* {@link GetAsyncSearchRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public final <TDocument> GetAsyncSearchResponse<TDocument> get(
Function<GetAsyncSearchRequest.Builder, ObjectBuilder<GetAsyncSearchRequest>> fn, Type tDocumentType)
throws IOException, ElasticsearchException {
return get(fn.apply(new GetAsyncSearchRequest.Builder()).build(), tDocumentType);
}

// ----- Endpoint: async_search.status

/**
Expand Down Expand Up @@ -171,6 +209,43 @@ public final <TDocument> AsyncSearchStatusResponse<TDocument> status(
return status(fn.apply(new AsyncSearchStatusRequest.Builder()).build(), tDocumentClass);
}

/**
* Retrieves the status of a previously submitted async search request given its
* ID.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public <TDocument> AsyncSearchStatusResponse<TDocument> status(AsyncSearchStatusRequest request, Type tDocumentType)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse>) AsyncSearchStatusRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:async_search.status.TDocument", getDeserializer(tDocumentType));

return this.transport.performRequest(request, endpoint, this.transportOptions);
}

/**
* Retrieves the status of a previously submitted async search request given its
* ID.
*
* @param fn
* a function that initializes a builder to create the
* {@link AsyncSearchStatusRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public final <TDocument> AsyncSearchStatusResponse<TDocument> status(
Function<AsyncSearchStatusRequest.Builder, ObjectBuilder<AsyncSearchStatusRequest>> fn, Type tDocumentType)
throws IOException, ElasticsearchException {
return status(fn.apply(new AsyncSearchStatusRequest.Builder()).build(), tDocumentType);
}

// ----- Endpoint: async_search.submit

/**
Expand Down Expand Up @@ -208,4 +283,39 @@ public final <TDocument> SubmitResponse<TDocument> submit(
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentClass);
}

/**
* Executes a search request asynchronously.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public <TDocument> SubmitResponse<TDocument> submit(SubmitRequest request, Type tDocumentType)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse>) SubmitRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:async_search.submit.TDocument", getDeserializer(tDocumentType));

return this.transport.performRequest(request, endpoint, this.transportOptions);
}

/**
* Executes a search request asynchronously.
*
* @param fn
* a function that initializes a builder to create the
* {@link SubmitRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
* on elastic.co</a>
*/

public final <TDocument> SubmitResponse<TDocument> submit(
Function<SubmitRequest.Builder, ObjectBuilder<SubmitRequest>> fn, Type tDocumentType)
throws IOException, ElasticsearchException {
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import co.elastic.clients.transport.TransportOptions;
import co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr;
import co.elastic.clients.util.ObjectBuilder;
import java.lang.reflect.Type;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -126,6 +127,41 @@ public final <TEvent> CompletableFuture<EqlGetResponse<TEvent>> get(
return get(fn.apply(new EqlGetRequest.Builder()).build(), tEventClass);
}

/**
* Returns async results from previously executed Event Query Language (EQL)
* search
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html">Documentation
* on elastic.co</a>
*/

public <TEvent> CompletableFuture<EqlGetResponse<TEvent>> get(EqlGetRequest request, Type tEventType) {
@SuppressWarnings("unchecked")
JsonEndpoint<EqlGetRequest, EqlGetResponse<TEvent>, ErrorResponse> endpoint = (JsonEndpoint<EqlGetRequest, EqlGetResponse<TEvent>, ErrorResponse>) EqlGetRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint, "co.elastic.clients:Deserializer:eql.get.TEvent",
getDeserializer(tEventType));

return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}

/**
* Returns async results from previously executed Event Query Language (EQL)
* search
*
* @param fn
* a function that initializes a builder to create the
* {@link EqlGetRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html">Documentation
* on elastic.co</a>
*/

public final <TEvent> CompletableFuture<EqlGetResponse<TEvent>> get(
Function<EqlGetRequest.Builder, ObjectBuilder<EqlGetRequest>> fn, Type tEventType) {
return get(fn.apply(new EqlGetRequest.Builder()).build(), tEventType);
}

// ----- Endpoint: eql.get_status

/**
Expand Down Expand Up @@ -197,4 +233,37 @@ public final <TEvent> CompletableFuture<EqlSearchResponse<TEvent>> search(
return search(fn.apply(new EqlSearchRequest.Builder()).build(), tEventClass);
}

/**
* Returns results matching a query expressed in Event Query Language (EQL)
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html">Documentation
* on elastic.co</a>
*/

public <TEvent> CompletableFuture<EqlSearchResponse<TEvent>> search(EqlSearchRequest request, Type tEventType) {
@SuppressWarnings("unchecked")
JsonEndpoint<EqlSearchRequest, EqlSearchResponse<TEvent>, ErrorResponse> endpoint = (JsonEndpoint<EqlSearchRequest, EqlSearchResponse<TEvent>, ErrorResponse>) EqlSearchRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint, "co.elastic.clients:Deserializer:eql.search.TEvent",
getDeserializer(tEventType));

return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}

/**
* Returns results matching a query expressed in Event Query Language (EQL)
*
* @param fn
* a function that initializes a builder to create the
* {@link EqlSearchRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html">Documentation
* on elastic.co</a>
*/

public final <TEvent> CompletableFuture<EqlSearchResponse<TEvent>> search(
Function<EqlSearchRequest.Builder, ObjectBuilder<EqlSearchRequest>> fn, Type tEventType) {
return search(fn.apply(new EqlSearchRequest.Builder()).build(), tEventType);
}

}

0 comments on commit 1d55a13

Please sign in to comment.