Skip to content

Commit 5b2e248

Browse files
authored
Merge branch 'main' into add.es.repo
2 parents d2ccf32 + 3e542c8 commit 5b2e248

File tree

2,488 files changed

+210873
-136277
lines changed

Some content is hidden

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

2,488 files changed

+210873
-136277
lines changed

config/checkstyle/checkstyle.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939
<!-- Checks Java files and forbids empty Javadoc comments. -->
4040
<!-- Although you can use the "JavadocStyle" rule for this, it considers Javadoc -->
4141
<!-- that only contains a "@return" line to be empty. -->
42+
<!--
4243
<module name="RegexpMultiline">
4344
<property name="id" value="EmptyJavadoc" />
4445
<property name="format" value="\/\*[\s\*]*\*\/" />
4546
<property name="fileExtensions" value="java" />
4647
<property name="message" value="Empty javadoc comments are forbidden" />
4748
</module>
49+
-->
4850

4951
<!-- Its our official line length! See checkstyle_suppressions.xml for the files that don't pass this. For now we
5052
suppress the check there but enforce it everywhere else. This prevents the list from getting longer even if it is

java-client/build.gradle.kts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@ publishing {
107107
}
108108

109109
dependencies {
110-
val elasticsearchVersion = "7.12.0"
110+
val elasticsearchVersion = "7.15.0"
111111
val jacksonVersion = "2.12.0"
112112

113113
// Apache 2.0
114+
// https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low.html
114115
implementation("org.elasticsearch.client", "elasticsearch-rest-client", elasticsearchVersion)
115116

116117
// Apache 2.0
118+
// https://search.maven.org/artifact/com.google.code.findbugs/jsr305
117119
implementation("com.google.code.findbugs:jsr305:3.0.2")
118120

119121
// EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
@@ -131,6 +133,7 @@ dependencies {
131133
testImplementation("jakarta.json.bind", "jakarta.json.bind-api", "2.0.0")
132134

133135
// Apache 2.0
136+
// https://github.com/FasterXML/jackson
134137
compileOnly("com.fasterxml.jackson.core", "jackson-core", jacksonVersion)
135138
compileOnly("com.fasterxml.jackson.core", "jackson-databind", jacksonVersion)
136139
testImplementation("com.fasterxml.jackson.core", "jackson-core", jacksonVersion)
@@ -140,10 +143,16 @@ dependencies {
140143
// https://eclipse-ee4j.github.io/yasson/
141144
testImplementation("org.eclipse", "yasson", "2.0.2")
142145

143-
// Eclipse 1.0
146+
// EPL-1.0
147+
// https://junit.org/junit4/
144148
testImplementation("junit", "junit" , "4.12")
145149

146150
// MIT
151+
// https://github.com/classgraph/classgraph
152+
testImplementation("io.github.classgraph:classgraph:4.8.116")
153+
154+
// MIT
155+
// https://www.testcontainers.org/
147156
testImplementation("org.testcontainers", "testcontainers", "1.15.3")
148157
testImplementation("org.testcontainers", "elasticsearch", "1.15.3")
149158
}

java-client/src/main/java/co/elastic/clients/base/AdditionalProperties.java

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

java-client/src/main/java/co/elastic/clients/base/ApiClient.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,27 @@
2020
package co.elastic.clients.base;
2121

2222
import co.elastic.clients.json.JsonpDeserializer;
23-
import org.elasticsearch.client.RequestOptions;
23+
import co.elastic.clients.json.JsonpMapperBase;
2424

25-
import javax.annotation.Nullable;
26-
27-
public abstract class ApiClient<Self extends ApiClient<Self>> {
25+
public abstract class ApiClient {
2826

2927
protected final Transport transport;
3028

31-
@Nullable
32-
protected final RequestOptions requestOptions;
33-
34-
protected ApiClient(Transport transport, @Nullable RequestOptions requestOptions) {
29+
protected ApiClient(Transport transport) {
3530
this.transport = transport;
36-
this.requestOptions = requestOptions;
3731
}
3832

39-
/**
40-
* Creates a new client with some request options
41-
*/
42-
public abstract Self withRequestOptions(@Nullable RequestOptions requestOptions);
33+
protected <T> JsonpDeserializer<T> getDeserializer(Class<T> clazz) {
34+
// Try the built-in deserializers first to avoid repeated lookups in the Jsonp mapper for client-defined classes
35+
JsonpDeserializer<T> result = JsonpMapperBase.findDeserializer(clazz);
36+
if (result != null) {
37+
return result;
38+
}
4339

44-
@Nullable
45-
public final RequestOptions requestOptions() {
46-
return this.requestOptions;
40+
return JsonpDeserializer.of(clazz);
4741
}
4842

49-
protected <T> JsonpDeserializer<T> getDeserializer(Class<T> clazz) {
50-
return transport.jsonpMapper().getDeserializer(clazz);
43+
public Transport _transport() {
44+
return this.transport;
5145
}
5246
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package co.elastic.clients.base;
21+
22+
import co.elastic.clients.json.JsonpDeserializer;
23+
24+
import java.util.Map;
25+
import java.util.function.Function;
26+
27+
public class BooleanEndpoint<RequestT> extends SimpleEndpoint<RequestT, BooleanResponse> {
28+
29+
public BooleanEndpoint(
30+
Function<RequestT, String> method,
31+
Function<RequestT, String> requestUrl,
32+
Function<RequestT,
33+
Map<String, String>> queryParameters,
34+
Function<RequestT, Map<String, String>> headers,
35+
boolean hasRequestBody, // always true
36+
JsonpDeserializer<BooleanResponse> responseParser // always null
37+
) {
38+
super(method, requestUrl, queryParameters, headers, hasRequestBody, responseParser);
39+
}
40+
41+
@Override
42+
public boolean isError(int statusCode) {
43+
return statusCode >= 500;
44+
}
45+
46+
public boolean getResult(int statusCode) {
47+
return statusCode < 400;
48+
}
49+
}

0 commit comments

Comments
 (0)