Skip to content

Commit c6870c2

Browse files
authored
Merge branch 'main' into mw-serverless-cleanup
2 parents 7ef91ba + 06164fb commit c6870c2

File tree

321 files changed

+38322
-2639
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

321 files changed

+38322
-2639
lines changed

example-transports/src/test/java/co/elastic/clients/transport/rest_client/RestTransportClientTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@
2020
package co.elastic.clients.transport.rest_client;
2121

2222
import co.elastic.clients.transport.TransportHttpClientTest;
23+
import co.elastic.clients.transport.rest5_client.Rest5ClientHttpClient;
2324
import org.apache.http.HttpHost;
2425
import org.elasticsearch.client.RestClient;
2526

26-
public class RestTransportClientTest extends TransportHttpClientTest<RestClientHttpClient> {
27+
public class RestTransportClientTest extends TransportHttpClientTest<Rest5ClientHttpClient> {
2728

2829
public RestTransportClientTest() {
2930
super(createClient());
3031
}
3132

32-
private static RestClientHttpClient createClient() {
33+
private static Rest5ClientHttpClient createClient() {
3334
RestClient restClient = RestClient.builder(
3435
new HttpHost(server.getAddress().getAddress(), server.getAddress().getPort(), "http")
3536
).build();
3637

37-
return new RestClientHttpClient(restClient);
38+
return new Rest5ClientHttpClient(restClient);
3839
}
3940
}

java-client/build.gradle.kts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ checkstyle {
3838
}
3939

4040
java {
41-
targetCompatibility = JavaVersion.VERSION_1_8
42-
sourceCompatibility = JavaVersion.VERSION_1_8
41+
targetCompatibility = JavaVersion.VERSION_17
42+
sourceCompatibility = JavaVersion.VERSION_17
4343

4444
withJavadocJar()
4545
withSourcesJar()
@@ -200,14 +200,16 @@ signing {
200200
dependencies {
201201
// Compile and test with the last 7.x version to make sure transition scenarios where
202202
// the Java API client coexists with a 7.x HLRC work fine
203-
val elasticsearchVersion = "8.10.0"
203+
val elasticsearchVersion = "8.17.0"
204204
val jacksonVersion = "2.17.0"
205205
val openTelemetryVersion = "1.29.0"
206206

207207
// Apache 2.0
208208
// https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low.html
209209
api("org.elasticsearch.client", "elasticsearch-rest-client", elasticsearchVersion)
210210

211+
api("org.apache.httpcomponents.client5","httpclient5","5.4")
212+
211213
// Apache 2.0
212214
// https://search.maven.org/artifact/com.google.code.findbugs/jsr305
213215
api("com.google.code.findbugs:jsr305:3.0.2")
@@ -271,6 +273,16 @@ dependencies {
271273
// Apache-2.0
272274
// https://github.com/awaitility/awaitility
273275
testImplementation("org.awaitility", "awaitility", "4.2.0")
276+
277+
// MIT
278+
// https://github.com/mockito/mockito
279+
testImplementation("org.mockito","mockito-core","5.12.0")
280+
281+
// Apache-2.0
282+
// https://github.com/elastic/mocksocket
283+
testImplementation("org.elasticsearch","mocksocket","1.2")
284+
285+
274286
}
275287

276288

@@ -285,6 +297,7 @@ class SpdxReporter(val dest: File) : ReportRenderer {
285297
"The Apache License, Version 2.0" to "Apache-2.0",
286298
"Apache License, Version 2.0" to "Apache-2.0",
287299
"The Apache Software License, Version 2.0" to "Apache-2.0",
300+
"MIT License" to "MIT",
288301
"BSD Zero Clause License" to "0BSD",
289302
"Eclipse Public License 2.0" to "EPL-2.0",
290303
"Eclipse Public License v. 2.0" to "EPL-2.0",
@@ -311,7 +324,11 @@ class SpdxReporter(val dest: File) : ReportRenderer {
311324
val depName = dep.group + ":" + dep.name
312325

313326
val info = LicenseDataCollector.multiModuleLicenseInfo(dep)
314-
val depUrl = info.moduleUrls.first()
327+
val depUrl = if (depName.startsWith("org.apache.httpcomponents")) {
328+
"https://hc.apache.org/"
329+
} else {
330+
info.moduleUrls.first()
331+
}
315332

316333
val licenseIds = info.licenses.mapNotNull { license ->
317334
license.name?.let {

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
import co.elastic.clients.elasticsearch.watcher.ElasticsearchWatcherAsyncClient;
147147
import co.elastic.clients.elasticsearch.xpack.ElasticsearchXpackAsyncClient;
148148
import co.elastic.clients.transport.ElasticsearchTransport;
149+
import co.elastic.clients.transport.ElasticsearchTransportConfig;
149150
import co.elastic.clients.transport.Endpoint;
150151
import co.elastic.clients.transport.JsonEndpoint;
151152
import co.elastic.clients.transport.Transport;
@@ -179,6 +180,23 @@
179180
*/
180181
public class ElasticsearchAsyncClient extends ApiClient<ElasticsearchTransport, ElasticsearchAsyncClient> {
181182

183+
/**
184+
* Creates a client from a {@link ElasticsearchTransportConfig.Default}}
185+
* configuration created with an inline lambda expression.
186+
*/
187+
public static ElasticsearchAsyncClient of(
188+
Function<ElasticsearchTransportConfig.Builder, ElasticsearchTransportConfig.Builder> fn) {
189+
return new ElasticsearchAsyncClient(
190+
fn.apply(new ElasticsearchTransportConfig.Builder()).build().buildTransport());
191+
}
192+
193+
/**
194+
* Creates a client from an {@link ElasticsearchTransportConfig}.
195+
*/
196+
public ElasticsearchAsyncClient(ElasticsearchTransportConfig config) {
197+
this(config.buildTransport());
198+
}
199+
182200
public ElasticsearchAsyncClient(ElasticsearchTransport transport) {
183201
super(transport, null);
184202
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
import co.elastic.clients.elasticsearch.watcher.ElasticsearchWatcherClient;
148148
import co.elastic.clients.elasticsearch.xpack.ElasticsearchXpackClient;
149149
import co.elastic.clients.transport.ElasticsearchTransport;
150+
import co.elastic.clients.transport.ElasticsearchTransportConfig;
150151
import co.elastic.clients.transport.Endpoint;
151152
import co.elastic.clients.transport.JsonEndpoint;
152153
import co.elastic.clients.transport.Transport;
@@ -180,6 +181,22 @@
180181
*/
181182
public class ElasticsearchClient extends ApiClient<ElasticsearchTransport, ElasticsearchClient> {
182183

184+
/**
185+
* Creates a client from a {@link ElasticsearchTransportConfig.Default}}
186+
* configuration created with an inline lambda expression.
187+
*/
188+
public static ElasticsearchClient of(
189+
Function<ElasticsearchTransportConfig.Builder, ElasticsearchTransportConfig.Builder> fn) {
190+
return new ElasticsearchClient(fn.apply(new ElasticsearchTransportConfig.Builder()).build().buildTransport());
191+
}
192+
193+
/**
194+
* Creates a client from an {@link ElasticsearchTransportConfig}.
195+
*/
196+
public ElasticsearchClient(ElasticsearchTransportConfig config) {
197+
this(config.buildTransport());
198+
}
199+
183200
public ElasticsearchClient(ElasticsearchTransport transport) {
184201
super(transport, null);
185202
}

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/Script.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
@JsonpDeserializable
6464
public class Script implements IntervalsFilterVariant, JsonpSerializable {
6565
@Nullable
66-
private final String source;
66+
private final ScriptSource source;
6767

6868
@Nullable
6969
private final String id;
@@ -105,7 +105,7 @@ public IntervalsFilter.Kind _intervalsFilterKind() {
105105
* API name: {@code source}
106106
*/
107107
@Nullable
108-
public final String source() {
108+
public final ScriptSource source() {
109109
return this.source;
110110
}
111111

@@ -159,7 +159,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
159159

160160
if (this.source != null) {
161161
generator.writeKey("source");
162-
generator.write(this.source);
162+
this.source.serialize(generator, mapper);
163163

164164
}
165165
if (this.id != null) {
@@ -210,7 +210,7 @@ public String toString() {
210210

211211
public static class Builder extends WithJsonObjectBuilderBase<Builder> implements ObjectBuilder<Script> {
212212
@Nullable
213-
private String source;
213+
private ScriptSource source;
214214

215215
@Nullable
216216
private String id;
@@ -229,11 +229,20 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder> implement
229229
* <p>
230230
* API name: {@code source}
231231
*/
232-
public final Builder source(@Nullable String value) {
232+
public final Builder source(@Nullable ScriptSource value) {
233233
this.source = value;
234234
return this;
235235
}
236236

237+
/**
238+
* The script source.
239+
* <p>
240+
* API name: {@code source}
241+
*/
242+
public final Builder source(Function<ScriptSource.Builder, ObjectBuilder<ScriptSource>> fn) {
243+
return this.source(fn.apply(new ScriptSource.Builder()).build());
244+
}
245+
237246
/**
238247
* The <code>id</code> for a stored script.
239248
* <p>
@@ -338,7 +347,7 @@ public Script build() {
338347

339348
protected static void setupScriptDeserializer(ObjectDeserializer<Script.Builder> op) {
340349

341-
op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source");
350+
op.add(Builder::source, ScriptSource._DESERIALIZER, "source");
342351
op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id");
343352
op.add(Builder::params, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "params");
344353
op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang");

0 commit comments

Comments
 (0)