Skip to content

Commit d5b93c9

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

15 files changed

+1426
-0
lines changed

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

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

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

Lines changed: 421 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: 70 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/8.6/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/8.6/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
/**
@@ -202,4 +239,37 @@ public final <TDocument> CompletableFuture<SubmitResponse<TDocument>> submit(
202239
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentClass);
203240
}
204241

242+
/**
243+
* Executes a search request asynchronously.
244+
*
245+
* @see <a href=
246+
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.6/async-search.html">Documentation
247+
* on elastic.co</a>
248+
*/
249+
250+
public <TDocument> CompletableFuture<SubmitResponse<TDocument>> submit(SubmitRequest request, Type tDocumentType) {
251+
@SuppressWarnings("unchecked")
252+
JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse>) SubmitRequest._ENDPOINT;
253+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
254+
"co.elastic.clients:Deserializer:async_search.submit.TDocument", getDeserializer(tDocumentType));
255+
256+
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
257+
}
258+
259+
/**
260+
* Executes a search request asynchronously.
261+
*
262+
* @param fn
263+
* a function that initializes a builder to create the
264+
* {@link SubmitRequest}
265+
* @see <a href=
266+
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.6/async-search.html">Documentation
267+
* on elastic.co</a>
268+
*/
269+
270+
public final <TDocument> CompletableFuture<SubmitResponse<TDocument>> submit(
271+
Function<SubmitRequest.Builder, ObjectBuilder<SubmitRequest>> fn, Type tDocumentType) {
272+
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentType);
273+
}
274+
205275
}

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

Lines changed: 73 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/8.6/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/8.6/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
/**
@@ -206,4 +244,39 @@ public final <TDocument> SubmitResponse<TDocument> submit(
206244
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentClass);
207245
}
208246

247+
/**
248+
* Executes a search request asynchronously.
249+
*
250+
* @see <a href=
251+
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.6/async-search.html">Documentation
252+
* on elastic.co</a>
253+
*/
254+
255+
public <TDocument> SubmitResponse<TDocument> submit(SubmitRequest request, Type tDocumentType)
256+
throws IOException, ElasticsearchException {
257+
@SuppressWarnings("unchecked")
258+
JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse>) SubmitRequest._ENDPOINT;
259+
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
260+
"co.elastic.clients:Deserializer:async_search.submit.TDocument", getDeserializer(tDocumentType));
261+
262+
return this.transport.performRequest(request, endpoint, this.transportOptions);
263+
}
264+
265+
/**
266+
* Executes a search request asynchronously.
267+
*
268+
* @param fn
269+
* a function that initializes a builder to create the
270+
* {@link SubmitRequest}
271+
* @see <a href=
272+
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.6/async-search.html">Documentation
273+
* on elastic.co</a>
274+
*/
275+
276+
public final <TDocument> SubmitResponse<TDocument> submit(
277+
Function<SubmitRequest.Builder, ObjectBuilder<SubmitRequest>> fn, Type tDocumentType)
278+
throws IOException, ElasticsearchException {
279+
return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentType);
280+
}
281+
209282
}

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
}

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

Lines changed: 72 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

@@ -128,6 +129,42 @@ public final <TEvent> EqlGetResponse<TEvent> get(Function<EqlGetRequest.Builder,
128129
return get(fn.apply(new EqlGetRequest.Builder()).build(), tEventClass);
129130
}
130131

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

133170
/**
@@ -201,4 +238,39 @@ public final <TEvent> EqlSearchResponse<TEvent> search(
201238
return search(fn.apply(new EqlSearchRequest.Builder()).build(), tEventClass);
202239
}
203240

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

0 commit comments

Comments
 (0)