Skip to content

Commit 45a074e

Browse files
authored
[Backport 9.3] Handle text endpoints (#1135) (#1136)
* Handle text endpoints (#1135) * correctly handling text endpoints * handle new text endnpoint in transport, tests * fix test
1 parent aafafee commit 45a074e

13 files changed

Lines changed: 195 additions & 172 deletions

File tree

java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatAsyncClient.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
import co.elastic.clients.ApiClient;
2323
import co.elastic.clients.elasticsearch._types.ErrorResponse;
2424
import co.elastic.clients.transport.ElasticsearchTransport;
25-
import co.elastic.clients.transport.Endpoint;
2625
import co.elastic.clients.transport.JsonEndpoint;
27-
import co.elastic.clients.transport.Transport;
2826
import co.elastic.clients.transport.TransportOptions;
27+
import co.elastic.clients.transport.endpoints.TextResponse;
2928
import co.elastic.clients.util.ObjectBuilder;
3029
import java.util.concurrent.CompletableFuture;
3130
import java.util.function.Function;
@@ -495,7 +494,7 @@ public CompletableFuture<HealthResponse> health() {
495494
* "https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-cat">Documentation
496495
* on elastic.co</a>
497496
*/
498-
public CompletableFuture<HelpResponse> help() {
497+
public CompletableFuture<TextResponse> help() {
499498
return this.transport.performRequestAsync(HelpRequest._INSTANCE, HelpRequest._ENDPOINT, this.transportOptions);
500499
}
501500

java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatClient.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
2424
import co.elastic.clients.elasticsearch._types.ErrorResponse;
2525
import co.elastic.clients.transport.ElasticsearchTransport;
26-
import co.elastic.clients.transport.Endpoint;
2726
import co.elastic.clients.transport.JsonEndpoint;
28-
import co.elastic.clients.transport.Transport;
2927
import co.elastic.clients.transport.TransportOptions;
28+
import co.elastic.clients.transport.endpoints.TextResponse;
3029
import co.elastic.clients.util.ObjectBuilder;
3130
import java.io.IOException;
3231
import java.util.function.Function;
@@ -498,7 +497,7 @@ public HealthResponse health() throws IOException, ElasticsearchException {
498497
* "https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-cat">Documentation
499498
* on elastic.co</a>
500499
*/
501-
public HelpResponse help() throws IOException, ElasticsearchException {
500+
public TextResponse help() throws IOException, ElasticsearchException {
502501
return this.transport.performRequest(HelpRequest._INSTANCE, HelpRequest._ENDPOINT, this.transportOptions);
503502
}
504503

java-client/src/main/java/co/elastic/clients/elasticsearch/cat/HelpRequest.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@
2020
package co.elastic.clients.elasticsearch.cat;
2121

2222
import co.elastic.clients.elasticsearch._types.ErrorResponse;
23-
import co.elastic.clients.json.JsonpDeserializable;
24-
import co.elastic.clients.json.JsonpDeserializer;
25-
import co.elastic.clients.json.ObjectBuilderDeserializer;
26-
import co.elastic.clients.json.ObjectDeserializer;
2723
import co.elastic.clients.transport.Endpoint;
2824
import co.elastic.clients.transport.endpoints.SimpleEndpoint;
29-
import co.elastic.clients.util.ObjectBuilder;
30-
import jakarta.json.stream.JsonGenerator;
25+
import co.elastic.clients.transport.endpoints.TextResponse;
26+
import co.elastic.clients.transport.endpoints.TextEndpoint;
27+
3128
import java.util.Collections;
32-
import java.util.Objects;
3329

3430
//----------------------------------------------------------------
3531
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
@@ -71,7 +67,7 @@ public HelpRequest() {
7167
/**
7268
* Endpoint "{@code cat.help}".
7369
*/
74-
public static final Endpoint<HelpRequest, HelpResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(
70+
public static final Endpoint<HelpRequest, TextResponse, ErrorResponse> _ENDPOINT = new TextEndpoint<>(
7571
"es/cat.help",
7672

7773
// Request method
@@ -95,5 +91,5 @@ public HelpRequest() {
9591
request -> {
9692
return Collections.emptyMap();
9793

98-
}, SimpleEndpoint.emptyMap(), false, HelpResponse._DESERIALIZER);
94+
}, SimpleEndpoint.emptyMap(), false, null);
9995
}

java-client/src/main/java/co/elastic/clients/elasticsearch/cat/HelpResponse.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,10 +1134,9 @@
11341134
'cat.health.HealthRecord': 'cat/health/types.ts#L23-L99',
11351135
'cat.health.Request': 'cat/health/CatHealthRequest.ts#L23-L65',
11361136
'cat.health.Response': 'cat/health/CatHealthResponse.ts#L22-L25',
1137-
'cat.help.Request': 'cat/help/CatHelpRequest.ts#L20-L36',
1138-
'cat.help.Response': 'cat/help/CatHelpResponse.ts#L20-L25',
1139-
'cat.indices.IndicesRecord': 'cat/indices/types.ts#L20-L808',
1140-
'cat.indices.Request': 'cat/indices/CatIndicesRequest.ts#L24-L99',
1137+
'cat.help.Request': 'cat/help/CatHelpRequest.ts#L22-L39',
1138+
'cat.indices.IndicesRecord': 'cat/indices/types.ts#L20-L812',
1139+
'cat.indices.Request': 'cat/indices/CatIndicesRequest.ts#L30-L107',
11411140
'cat.indices.Response': 'cat/indices/CatIndicesResponse.ts#L22-L25',
11421141
'cat.master.MasterRecord': 'cat/master/types.ts#L20-L39',
11431142
'cat.master.Request': 'cat/master/CatMasterRequest.ts#L24-L68',
@@ -2645,9 +2644,8 @@
26452644
'nodes.get_repositories_metering_info.Request': 'nodes/get_repositories_metering_info/GetRepositoriesMeteringInfoRequest.ts#L23-L49',
26462645
'nodes.get_repositories_metering_info.Response': 'nodes/get_repositories_metering_info/GetRepositoriesMeteringInfoResponse.ts#L36-L39',
26472646
'nodes.get_repositories_metering_info.ResponseBase': 'nodes/get_repositories_metering_info/GetRepositoriesMeteringInfoResponse.ts#L25-L34',
2648-
'nodes.hot_threads.Request': 'nodes/hot_threads/NodesHotThreadsRequest.ts#L25-L88',
2649-
'nodes.hot_threads.Response': 'nodes/hot_threads/NodesHotThreadsResponse.ts#L20-L22',
2650-
'nodes.info.DeprecationIndexing': 'nodes/info/types.ts#L154-L156',
2647+
'nodes.hot_threads.Request': 'nodes/hot_threads/NodesHotThreadsRequest.ts#L25-L94',
2648+
'nodes.info.DeprecationIndexing': 'nodes/info/types.ts#L154-L157',
26512649
'nodes.info.NodeInfo': 'nodes/info/types.ts#L32-L72',
26522650
'nodes.info.NodeInfoAction': 'nodes/info/types.ts#L194-L196',
26532651
'nodes.info.NodeInfoAggregation': 'nodes/info/types.ts#L250-L252',

java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/ElasticsearchNodesAsyncClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import co.elastic.clients.transport.ElasticsearchTransport;
2525
import co.elastic.clients.transport.Endpoint;
2626
import co.elastic.clients.transport.JsonEndpoint;
27-
import co.elastic.clients.transport.Transport;
2827
import co.elastic.clients.transport.TransportOptions;
28+
import co.elastic.clients.transport.endpoints.TextResponse;
2929
import co.elastic.clients.util.ObjectBuilder;
3030
import java.util.concurrent.CompletableFuture;
3131
import java.util.function.Function;
@@ -158,9 +158,9 @@ public final CompletableFuture<GetRepositoriesMeteringInfoResponse> getRepositor
158158
* on elastic.co</a>
159159
*/
160160

161-
public CompletableFuture<HotThreadsResponse> hotThreads(HotThreadsRequest request) {
161+
public CompletableFuture<TextResponse> hotThreads(HotThreadsRequest request) {
162162
@SuppressWarnings("unchecked")
163-
JsonEndpoint<HotThreadsRequest, HotThreadsResponse, ErrorResponse> endpoint = (JsonEndpoint<HotThreadsRequest, HotThreadsResponse, ErrorResponse>) HotThreadsRequest._ENDPOINT;
163+
Endpoint<HotThreadsRequest, TextResponse, ErrorResponse> endpoint = (Endpoint<HotThreadsRequest, TextResponse, ErrorResponse>) HotThreadsRequest._ENDPOINT;
164164

165165
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
166166
}
@@ -178,7 +178,7 @@ public CompletableFuture<HotThreadsResponse> hotThreads(HotThreadsRequest reques
178178
* on elastic.co</a>
179179
*/
180180

181-
public final CompletableFuture<HotThreadsResponse> hotThreads(
181+
public final CompletableFuture<TextResponse> hotThreads(
182182
Function<HotThreadsRequest.Builder, ObjectBuilder<HotThreadsRequest>> fn) {
183183
return hotThreads(fn.apply(new HotThreadsRequest.Builder()).build());
184184
}
@@ -193,7 +193,7 @@ public final CompletableFuture<HotThreadsResponse> hotThreads(
193193
* on elastic.co</a>
194194
*/
195195

196-
public CompletableFuture<HotThreadsResponse> hotThreads() {
196+
public CompletableFuture<TextResponse> hotThreads() {
197197
return this.transport.performRequestAsync(new HotThreadsRequest.Builder().build(), HotThreadsRequest._ENDPOINT,
198198
this.transportOptions);
199199
}

java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/ElasticsearchNodesClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import co.elastic.clients.transport.ElasticsearchTransport;
2626
import co.elastic.clients.transport.Endpoint;
2727
import co.elastic.clients.transport.JsonEndpoint;
28-
import co.elastic.clients.transport.Transport;
2928
import co.elastic.clients.transport.TransportOptions;
29+
import co.elastic.clients.transport.endpoints.TextResponse;
3030
import co.elastic.clients.util.ObjectBuilder;
3131
import java.io.IOException;
3232
import java.util.function.Function;
@@ -160,9 +160,9 @@ public final GetRepositoriesMeteringInfoResponse getRepositoriesMeteringInfo(
160160
* on elastic.co</a>
161161
*/
162162

163-
public HotThreadsResponse hotThreads(HotThreadsRequest request) throws IOException, ElasticsearchException {
163+
public TextResponse hotThreads(HotThreadsRequest request) throws IOException, ElasticsearchException {
164164
@SuppressWarnings("unchecked")
165-
JsonEndpoint<HotThreadsRequest, HotThreadsResponse, ErrorResponse> endpoint = (JsonEndpoint<HotThreadsRequest, HotThreadsResponse, ErrorResponse>) HotThreadsRequest._ENDPOINT;
165+
Endpoint<HotThreadsRequest, TextResponse, ErrorResponse> endpoint = (Endpoint<HotThreadsRequest, TextResponse, ErrorResponse>) HotThreadsRequest._ENDPOINT;
166166

167167
return this.transport.performRequest(request, endpoint, this.transportOptions);
168168
}
@@ -180,7 +180,7 @@ public HotThreadsResponse hotThreads(HotThreadsRequest request) throws IOExcepti
180180
* on elastic.co</a>
181181
*/
182182

183-
public final HotThreadsResponse hotThreads(Function<HotThreadsRequest.Builder, ObjectBuilder<HotThreadsRequest>> fn)
183+
public final TextResponse hotThreads(Function<HotThreadsRequest.Builder, ObjectBuilder<HotThreadsRequest>> fn)
184184
throws IOException, ElasticsearchException {
185185
return hotThreads(fn.apply(new HotThreadsRequest.Builder()).build());
186186
}
@@ -195,7 +195,7 @@ public final HotThreadsResponse hotThreads(Function<HotThreadsRequest.Builder, O
195195
* on elastic.co</a>
196196
*/
197197

198-
public HotThreadsResponse hotThreads() throws IOException, ElasticsearchException {
198+
public TextResponse hotThreads() throws IOException, ElasticsearchException {
199199
return this.transport.performRequest(new HotThreadsRequest.Builder().build(), HotThreadsRequest._ENDPOINT,
200200
this.transportOptions);
201201
}

java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/HotThreadsRequest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,19 @@
2323
import co.elastic.clients.elasticsearch._types.RequestBase;
2424
import co.elastic.clients.elasticsearch._types.ThreadType;
2525
import co.elastic.clients.elasticsearch._types.Time;
26-
import co.elastic.clients.json.JsonpDeserializable;
27-
import co.elastic.clients.json.JsonpDeserializer;
28-
import co.elastic.clients.json.ObjectBuilderDeserializer;
29-
import co.elastic.clients.json.ObjectDeserializer;
3026
import co.elastic.clients.transport.Endpoint;
3127
import co.elastic.clients.transport.endpoints.SimpleEndpoint;
28+
import co.elastic.clients.transport.endpoints.TextResponse;
29+
import co.elastic.clients.transport.endpoints.TextEndpoint;
3230
import co.elastic.clients.util.ApiTypeHelper;
3331
import co.elastic.clients.util.ObjectBuilder;
34-
import jakarta.json.stream.JsonGenerator;
32+
3533
import java.lang.Boolean;
3634
import java.lang.Long;
3735
import java.lang.String;
3836
import java.util.HashMap;
3937
import java.util.List;
4038
import java.util.Map;
41-
import java.util.Objects;
4239
import java.util.function.Function;
4340
import java.util.stream.Collectors;
4441
import javax.annotation.Nullable;
@@ -364,7 +361,7 @@ public HotThreadsRequest build() {
364361
/**
365362
* Endpoint "{@code nodes.hot_threads}".
366363
*/
367-
public static final Endpoint<HotThreadsRequest, HotThreadsResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(
364+
public static final Endpoint<HotThreadsRequest, TextResponse, ErrorResponse> _ENDPOINT = new TextEndpoint<>(
368365
"es/nodes.hot_threads",
369366

370367
// Request method
@@ -445,5 +442,5 @@ public HotThreadsRequest build() {
445442
}
446443
return params;
447444

448-
}, SimpleEndpoint.emptyMap(), false, HotThreadsResponse._DESERIALIZER);
445+
}, SimpleEndpoint.emptyMap(), false, null);
449446
}

java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/HotThreadsResponse.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)