Skip to content

Commit 1d55a13

Browse files
committed
[codegen] Add Type in addition to Class to map types with generic parameters
1 parent 1721de8 commit 1d55a13

12 files changed

+1333
-0
lines changed

java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchAsyncClient.java

Lines changed: 374 additions & 0 deletions
Large diffs are not rendered by default.

java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchClient.java

Lines changed: 386 additions & 0 deletions
Large diffs are not rendered by default.

java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/ElasticsearchAsyncSearchAsyncClient.java

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import co.elastic.clients.transport.TransportOptions;
3333
import co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr;
3434
import co.elastic.clients.util.ObjectBuilder;
35+
import java.lang.reflect.Type;
3536
import java.util.concurrent.CompletableFuture;
3637
import java.util.function.Function;
3738
import javax.annotation.Nullable;
@@ -131,6 +132,42 @@ public final <TDocument> CompletableFuture<GetAsyncSearchResponse<TDocument>> ge
131132
return get(fn.apply(new GetAsyncSearchRequest.Builder()).build(), tDocumentClass);
132133
}
133134

135+
/**
136+
* Retrieves the results of a previously submitted async search request given
137+
* its ID.
138+
*
139+
* @see <a href=
140+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
141+
* on elastic.co</a>
142+
*/
143+
144+
public <TDocument> CompletableFuture<GetAsyncSearchResponse<TDocument>> get(GetAsyncSearchRequest request,
145+
Type tDocumentType) {
146+
@SuppressWarnings("unchecked")
147+
JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse>) GetAsyncSearchRequest._ENDPOINT;
148+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
149+
"co.elastic.clients:Deserializer:async_search.get.TDocument", getDeserializer(tDocumentType));
150+
151+
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
152+
}
153+
154+
/**
155+
* Retrieves the results of a previously submitted async search request given
156+
* its ID.
157+
*
158+
* @param fn
159+
* a function that initializes a builder to create the
160+
* {@link GetAsyncSearchRequest}
161+
* @see <a href=
162+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
163+
* on elastic.co</a>
164+
*/
165+
166+
public final <TDocument> CompletableFuture<GetAsyncSearchResponse<TDocument>> get(
167+
Function<GetAsyncSearchRequest.Builder, ObjectBuilder<GetAsyncSearchRequest>> fn, Type tDocumentType) {
168+
return get(fn.apply(new GetAsyncSearchRequest.Builder()).build(), tDocumentType);
169+
}
170+
134171
// ----- Endpoint: async_search.status
135172

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

210+
/**
211+
* Retrieves the status of a previously submitted async search request given its
212+
* ID.
213+
*
214+
* @see <a href=
215+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
216+
* on elastic.co</a>
217+
*/
218+
219+
public <TDocument> CompletableFuture<AsyncSearchStatusResponse<TDocument>> status(AsyncSearchStatusRequest request,
220+
Type tDocumentType) {
221+
@SuppressWarnings("unchecked")
222+
JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse>) AsyncSearchStatusRequest._ENDPOINT;
223+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
224+
"co.elastic.clients:Deserializer:async_search.status.TDocument", getDeserializer(tDocumentType));
225+
226+
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
227+
}
228+
229+
/**
230+
* Retrieves the status of a previously submitted async search request given its
231+
* ID.
232+
*
233+
* @param fn
234+
* a function that initializes a builder to create the
235+
* {@link AsyncSearchStatusRequest}
236+
* @see <a href=
237+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
238+
* on elastic.co</a>
239+
*/
240+
241+
public final <TDocument> CompletableFuture<AsyncSearchStatusResponse<TDocument>> status(
242+
Function<AsyncSearchStatusRequest.Builder, ObjectBuilder<AsyncSearchStatusRequest>> fn,
243+
Type tDocumentType) {
244+
return status(fn.apply(new AsyncSearchStatusRequest.Builder()).build(), tDocumentType);
245+
}
246+
173247
// ----- Endpoint: async_search.submit
174248

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

283+
/**
284+
* Executes a search request asynchronously.
285+
*
286+
* @see <a href=
287+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
288+
* on elastic.co</a>
289+
*/
290+
291+
public <TDocument> CompletableFuture<SubmitResponse<TDocument>> submit(SubmitRequest request, Type tDocumentType) {
292+
@SuppressWarnings("unchecked")
293+
JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse>) SubmitRequest._ENDPOINT;
294+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
295+
"co.elastic.clients:Deserializer:async_search.submit.TDocument", getDeserializer(tDocumentType));
296+
297+
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
298+
}
299+
300+
/**
301+
* Executes a search request asynchronously.
302+
*
303+
* @param fn
304+
* a function that initializes a builder to create the
305+
* {@link SubmitRequest}
306+
* @see <a href=
307+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
308+
* on elastic.co</a>
309+
*/
310+
311+
public final <TDocument> CompletableFuture<SubmitResponse<TDocument>> submit(
312+
Function<SubmitRequest.Builder, ObjectBuilder<SubmitRequest>> fn, Type tDocumentType) {
313+
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentType);
314+
}
315+
209316
}

java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/ElasticsearchAsyncSearchClient.java

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr;
3535
import co.elastic.clients.util.ObjectBuilder;
3636
import java.io.IOException;
37+
import java.lang.reflect.Type;
3738
import java.util.function.Function;
3839
import javax.annotation.Nullable;
3940

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

136+
/**
137+
* Retrieves the results of a previously submitted async search request given
138+
* its ID.
139+
*
140+
* @see <a href=
141+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
142+
* on elastic.co</a>
143+
*/
144+
145+
public <TDocument> GetAsyncSearchResponse<TDocument> get(GetAsyncSearchRequest request, Type tDocumentType)
146+
throws IOException, ElasticsearchException {
147+
@SuppressWarnings("unchecked")
148+
JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse>) GetAsyncSearchRequest._ENDPOINT;
149+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
150+
"co.elastic.clients:Deserializer:async_search.get.TDocument", getDeserializer(tDocumentType));
151+
152+
return this.transport.performRequest(request, endpoint, this.transportOptions);
153+
}
154+
155+
/**
156+
* Retrieves the results of a previously submitted async search request given
157+
* its ID.
158+
*
159+
* @param fn
160+
* a function that initializes a builder to create the
161+
* {@link GetAsyncSearchRequest}
162+
* @see <a href=
163+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
164+
* on elastic.co</a>
165+
*/
166+
167+
public final <TDocument> GetAsyncSearchResponse<TDocument> get(
168+
Function<GetAsyncSearchRequest.Builder, ObjectBuilder<GetAsyncSearchRequest>> fn, Type tDocumentType)
169+
throws IOException, ElasticsearchException {
170+
return get(fn.apply(new GetAsyncSearchRequest.Builder()).build(), tDocumentType);
171+
}
172+
135173
// ----- Endpoint: async_search.status
136174

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

212+
/**
213+
* Retrieves the status of a previously submitted async search request given its
214+
* ID.
215+
*
216+
* @see <a href=
217+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
218+
* on elastic.co</a>
219+
*/
220+
221+
public <TDocument> AsyncSearchStatusResponse<TDocument> status(AsyncSearchStatusRequest request, Type tDocumentType)
222+
throws IOException, ElasticsearchException {
223+
@SuppressWarnings("unchecked")
224+
JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse>) AsyncSearchStatusRequest._ENDPOINT;
225+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
226+
"co.elastic.clients:Deserializer:async_search.status.TDocument", getDeserializer(tDocumentType));
227+
228+
return this.transport.performRequest(request, endpoint, this.transportOptions);
229+
}
230+
231+
/**
232+
* Retrieves the status of a previously submitted async search request given its
233+
* ID.
234+
*
235+
* @param fn
236+
* a function that initializes a builder to create the
237+
* {@link AsyncSearchStatusRequest}
238+
* @see <a href=
239+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
240+
* on elastic.co</a>
241+
*/
242+
243+
public final <TDocument> AsyncSearchStatusResponse<TDocument> status(
244+
Function<AsyncSearchStatusRequest.Builder, ObjectBuilder<AsyncSearchStatusRequest>> fn, Type tDocumentType)
245+
throws IOException, ElasticsearchException {
246+
return status(fn.apply(new AsyncSearchStatusRequest.Builder()).build(), tDocumentType);
247+
}
248+
174249
// ----- Endpoint: async_search.submit
175250

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

286+
/**
287+
* Executes a search request asynchronously.
288+
*
289+
* @see <a href=
290+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
291+
* on elastic.co</a>
292+
*/
293+
294+
public <TDocument> SubmitResponse<TDocument> submit(SubmitRequest request, Type tDocumentType)
295+
throws IOException, ElasticsearchException {
296+
@SuppressWarnings("unchecked")
297+
JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse>) SubmitRequest._ENDPOINT;
298+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
299+
"co.elastic.clients:Deserializer:async_search.submit.TDocument", getDeserializer(tDocumentType));
300+
301+
return this.transport.performRequest(request, endpoint, this.transportOptions);
302+
}
303+
304+
/**
305+
* Executes a search request asynchronously.
306+
*
307+
* @param fn
308+
* a function that initializes a builder to create the
309+
* {@link SubmitRequest}
310+
* @see <a href=
311+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation
312+
* on elastic.co</a>
313+
*/
314+
315+
public final <TDocument> SubmitResponse<TDocument> submit(
316+
Function<SubmitRequest.Builder, ObjectBuilder<SubmitRequest>> fn, Type tDocumentType)
317+
throws IOException, ElasticsearchException {
318+
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentType);
319+
}
320+
211321
}

java-client/src/main/java/co/elastic/clients/elasticsearch/eql/ElasticsearchEqlAsyncClient.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import co.elastic.clients.transport.TransportOptions;
3333
import co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr;
3434
import co.elastic.clients.util.ObjectBuilder;
35+
import java.lang.reflect.Type;
3536
import java.util.concurrent.CompletableFuture;
3637
import java.util.function.Function;
3738
import javax.annotation.Nullable;
@@ -126,6 +127,41 @@ public final <TEvent> CompletableFuture<EqlGetResponse<TEvent>> get(
126127
return get(fn.apply(new EqlGetRequest.Builder()).build(), tEventClass);
127128
}
128129

130+
/**
131+
* Returns async results from previously executed Event Query Language (EQL)
132+
* search
133+
*
134+
* @see <a href=
135+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html">Documentation
136+
* on elastic.co</a>
137+
*/
138+
139+
public <TEvent> CompletableFuture<EqlGetResponse<TEvent>> get(EqlGetRequest request, Type tEventType) {
140+
@SuppressWarnings("unchecked")
141+
JsonEndpoint<EqlGetRequest, EqlGetResponse<TEvent>, ErrorResponse> endpoint = (JsonEndpoint<EqlGetRequest, EqlGetResponse<TEvent>, ErrorResponse>) EqlGetRequest._ENDPOINT;
142+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint, "co.elastic.clients:Deserializer:eql.get.TEvent",
143+
getDeserializer(tEventType));
144+
145+
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
146+
}
147+
148+
/**
149+
* Returns async results from previously executed Event Query Language (EQL)
150+
* search
151+
*
152+
* @param fn
153+
* a function that initializes a builder to create the
154+
* {@link EqlGetRequest}
155+
* @see <a href=
156+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html">Documentation
157+
* on elastic.co</a>
158+
*/
159+
160+
public final <TEvent> CompletableFuture<EqlGetResponse<TEvent>> get(
161+
Function<EqlGetRequest.Builder, ObjectBuilder<EqlGetRequest>> fn, Type tEventType) {
162+
return get(fn.apply(new EqlGetRequest.Builder()).build(), tEventType);
163+
}
164+
129165
// ----- Endpoint: eql.get_status
130166

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

236+
/**
237+
* Returns results matching a query expressed in Event Query Language (EQL)
238+
*
239+
* @see <a href=
240+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html">Documentation
241+
* on elastic.co</a>
242+
*/
243+
244+
public <TEvent> CompletableFuture<EqlSearchResponse<TEvent>> search(EqlSearchRequest request, Type tEventType) {
245+
@SuppressWarnings("unchecked")
246+
JsonEndpoint<EqlSearchRequest, EqlSearchResponse<TEvent>, ErrorResponse> endpoint = (JsonEndpoint<EqlSearchRequest, EqlSearchResponse<TEvent>, ErrorResponse>) EqlSearchRequest._ENDPOINT;
247+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint, "co.elastic.clients:Deserializer:eql.search.TEvent",
248+
getDeserializer(tEventType));
249+
250+
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
251+
}
252+
253+
/**
254+
* Returns results matching a query expressed in Event Query Language (EQL)
255+
*
256+
* @param fn
257+
* a function that initializes a builder to create the
258+
* {@link EqlSearchRequest}
259+
* @see <a href=
260+
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html">Documentation
261+
* on elastic.co</a>
262+
*/
263+
264+
public final <TEvent> CompletableFuture<EqlSearchResponse<TEvent>> search(
265+
Function<EqlSearchRequest.Builder, ObjectBuilder<EqlSearchRequest>> fn, Type tEventType) {
266+
return search(fn.apply(new EqlSearchRequest.Builder()).build(), tEventType);
267+
}
268+
200269
}

0 commit comments

Comments
 (0)