Skip to content

Commit 0af73c2

Browse files
committed
Update generated code
1 parent 28333bd commit 0af73c2

File tree

545 files changed

+2841
-2509
lines changed

Some content is hidden

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

545 files changed

+2841
-2509
lines changed

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

Lines changed: 38 additions & 37 deletions
Large diffs are not rendered by default.

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

Lines changed: 38 additions & 37 deletions
Large diffs are not rendered by default.

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

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

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@
3030
public class ElasticsearchException extends RuntimeException {
3131

3232
private final ErrorResponse response;
33+
private final String endpointId;
3334

34-
public ElasticsearchException(ErrorResponse response) {
35-
super(response.error().type() != null
36-
? "[" + response.error().type() + "] " + response.error().reason()
37-
: response.error().reason());
35+
public ElasticsearchException(String endpointId, ErrorResponse response) {
36+
super("[" + endpointId + "] failed: [" + response.error().type() + "] " + response.error().reason());
3837
this.response = response;
38+
this.endpointId = endpointId;
39+
}
40+
41+
/**
42+
* Identifier of the API endpoint that failed to be called.
43+
*/
44+
public String endpointId() {
45+
return this.endpointId;
3946
}
4047

4148
/**
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
2222
//----------------------------------------------------
2323

24-
package co.elastic.clients.elasticsearch.core.search;
24+
package co.elastic.clients.elasticsearch._types;
2525

2626
import co.elastic.clients.elasticsearch._types.mapping.FieldType;
2727
import co.elastic.clients.json.JsonpDeserializable;
@@ -39,7 +39,7 @@
3939
import java.util.function.Consumer;
4040
import javax.annotation.Nullable;
4141

42-
// typedef: _global.search._types.FieldSort
42+
// typedef: _types.FieldSort
4343
@JsonpDeserializable
4444
public class FieldSort implements JsonpSerializable {
4545
// Single key dictionary
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
2222
//----------------------------------------------------
2323

24-
package co.elastic.clients.elasticsearch.core.search;
24+
package co.elastic.clients.elasticsearch._types;
2525

2626
import co.elastic.clients.json.JsonEnum;
2727
import co.elastic.clients.json.JsonpDeserializable;

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

Lines changed: 85 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,22 @@
2727
import co.elastic.clients.json.JsonpDeserializer;
2828
import co.elastic.clients.json.JsonpMapper;
2929
import co.elastic.clients.json.JsonpSerializable;
30+
import co.elastic.clients.json.JsonpUtils;
3031
import co.elastic.clients.json.ObjectDeserializer;
31-
import co.elastic.clients.json.UnionDeserializer;
3232
import co.elastic.clients.util.ModelTypeHelper;
3333
import co.elastic.clients.util.ObjectBuilder;
3434
import co.elastic.clients.util.ObjectBuilderBase;
3535
import co.elastic.clients.util.TaggedUnion;
3636
import co.elastic.clients.util.TaggedUnionUtils;
3737
import jakarta.json.stream.JsonGenerator;
38+
import jakarta.json.stream.JsonParser;
39+
3840
import java.lang.Boolean;
3941
import java.lang.Double;
4042
import java.lang.Long;
4143
import java.lang.Object;
4244
import java.lang.String;
45+
import java.util.EnumSet;
4346
import java.util.Objects;
4447
import java.util.function.Consumer;
4548
import javax.annotation.Nullable;
@@ -50,8 +53,7 @@
5053
public class FieldValue implements TaggedUnion<FieldValue.Kind, Object>, JsonpSerializable {
5154

5255
public enum Kind {
53-
Double, Long, Boolean, String
54-
56+
Double, Long, Boolean, String, Null
5557
}
5658

5759
private final Kind _kind;
@@ -67,11 +69,6 @@ public final Object _get() {
6769
return _value;
6870
}
6971

70-
public FieldValue(Kind kind, Object value) {
71-
this._kind = kind;
72-
this._value = value;
73-
}
74-
7572
public String _toJsonString() {
7673
switch (_kind) {
7774
case Double :
@@ -82,6 +79,8 @@ public String _toJsonString() {
8279
return String.valueOf(this.boolean_());
8380
case String :
8481
return this.string();
82+
case Null :
83+
return "null";
8584

8685
default :
8786
throw new IllegalStateException("Unknown kind " + _kind);
@@ -91,7 +90,9 @@ public String _toJsonString() {
9190
private FieldValue(Builder builder) {
9291

9392
this._kind = ModelTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
94-
this._value = ModelTypeHelper.requireNonNull(builder._value, builder, "<variant value>");
93+
this._value = this._kind == Kind.Null
94+
? null
95+
: ModelTypeHelper.requireNonNull(builder._value, builder, "<variant value>");
9596

9697
}
9798

@@ -114,7 +115,7 @@ public boolean isDouble() {
114115
* @throws IllegalStateException
115116
* if the current variant is not of the {@code double} kind.
116117
*/
117-
public Double double_() {
118+
public double double_() {
118119
return TaggedUnionUtils.get(this, Kind.Double);
119120
}
120121

@@ -131,7 +132,7 @@ public boolean isLong() {
131132
* @throws IllegalStateException
132133
* if the current variant is not of the {@code long} kind.
133134
*/
134-
public Long long_() {
135+
public long long_() {
135136
return TaggedUnionUtils.get(this, Kind.Long);
136137
}
137138

@@ -148,7 +149,7 @@ public boolean isBoolean() {
148149
* @throws IllegalStateException
149150
* if the current variant is not of the {@code boolean} kind.
150151
*/
151-
public Boolean boolean_() {
152+
public boolean boolean_() {
152153
return TaggedUnionUtils.get(this, Kind.Boolean);
153154
}
154155

@@ -169,76 +170,113 @@ public String string() {
169170
return TaggedUnionUtils.get(this, Kind.String);
170171
}
171172

173+
/**
174+
* Is this variant instance of kind {@code null}?
175+
*/
176+
public boolean isNull() {
177+
return _kind == Kind.Null;
178+
}
179+
180+
/**
181+
* Get the {@code null} variant value.
182+
*
183+
* @throws IllegalStateException
184+
* if the current variant is not of the {@code null} kind.
185+
*/
186+
public String null_() {
187+
return TaggedUnionUtils.get(this, Kind.Null);
188+
}
189+
172190
@Override
173191
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
174-
if (_value instanceof JsonpSerializable) {
175-
((JsonpSerializable) _value).serialize(generator, mapper);
176-
} else {
177-
switch (_kind) {
178-
case Double :
179-
generator.write(((Double) this._value));
180-
181-
break;
182-
case Long :
183-
generator.write(((Long) this._value));
184-
185-
break;
186-
case Boolean :
187-
generator.write(((Boolean) this._value));
188-
189-
break;
190-
case String :
191-
generator.write(((String) this._value));
192-
193-
break;
194-
}
192+
switch (_kind) {
193+
case Double :
194+
generator.write(((Double) this._value));
195+
break;
196+
case Long :
197+
generator.write(((Long) this._value));
198+
break;
199+
case Boolean :
200+
generator.write(((Boolean) this._value));
201+
break;
202+
case String :
203+
generator.write(((String) this._value));
204+
break;
205+
case Null :
206+
generator.writeNull();
207+
break;
195208
}
196-
197209
}
198210

199211
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<FieldValue> {
200212
private Kind _kind;
201213
private Object _value;
202214

203-
public Builder double_(Double v) {
215+
public ObjectBuilder<FieldValue> double_(double v) {
204216
this._kind = Kind.Double;
205217
this._value = v;
206218
return this;
207219
}
208220

209-
public Builder long_(Long v) {
221+
public ObjectBuilder<FieldValue> long_(long v) {
210222
this._kind = Kind.Long;
211223
this._value = v;
212224
return this;
213225
}
214226

215-
public Builder boolean_(Boolean v) {
227+
public ObjectBuilder<FieldValue> boolean_(boolean v) {
216228
this._kind = Kind.Boolean;
217229
this._value = v;
218230
return this;
219231
}
220232

221-
public Builder string(String v) {
233+
public ObjectBuilder<FieldValue> string(String v) {
222234
this._kind = Kind.String;
223235
this._value = v;
224236
return this;
225237
}
226238

239+
public ObjectBuilder<FieldValue> null_() {
240+
this._kind = Kind.Null;
241+
this._value = null;
242+
return this;
243+
}
244+
227245
public FieldValue build() {
228246
_checkSingleUse();
229247
return new FieldValue(this);
230248
}
231249

232250
}
233251

234-
private static JsonpDeserializer<FieldValue> buildFieldValueDeserializer() {
235-
return new UnionDeserializer.Builder<FieldValue, Kind, Object>(FieldValue::new, true)
236-
.addMember(Kind.Double, JsonpDeserializer.doubleDeserializer())
237-
.addMember(Kind.Long, JsonpDeserializer.longDeserializer())
238-
.addMember(Kind.Boolean, JsonpDeserializer.booleanDeserializer())
239-
.addMember(Kind.String, JsonpDeserializer.stringDeserializer()).build();
240-
}
241-
242252
public static final JsonpDeserializer<FieldValue> _DESERIALIZER = JsonpDeserializer
243-
.lazy(FieldValue::buildFieldValueDeserializer);
253+
.lazy(() -> JsonpDeserializer.of(
254+
EnumSet.of(JsonParser.Event.VALUE_STRING, JsonParser.Event.VALUE_NUMBER,
255+
JsonParser.Event.VALUE_NULL, JsonParser.Event.VALUE_TRUE, JsonParser.Event.VALUE_FALSE),
256+
(parser, mapper, event) -> {
257+
FieldValue.Builder b = new FieldValue.Builder();
258+
switch (event) {
259+
case VALUE_NULL :
260+
b.null_();
261+
break;
262+
case VALUE_STRING :
263+
b.string(parser.getString());
264+
break;
265+
case VALUE_TRUE :
266+
b.boolean_(Boolean.TRUE);
267+
break;
268+
case VALUE_FALSE :
269+
b.boolean_(Boolean.FALSE);
270+
break;
271+
case VALUE_NUMBER :
272+
if (parser.isIntegralNumber()) {
273+
b.long_(parser.getLong());
274+
} else {
275+
b.double_(parser.getBigDecimal().doubleValue());
276+
}
277+
break;
278+
}
279+
return b.build();
280+
}));
281+
244282
}

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

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

0 commit comments

Comments
 (0)