Skip to content

Commit e2912c3

Browse files
committed
[codegen] update to latest spec (+ fixed esql adapter)
1 parent 27f87e6 commit e2912c3

File tree

17 files changed

+2276
-243
lines changed

17 files changed

+2276
-243
lines changed

java-client/src/main/java/co/elastic/clients/elasticsearch/_helpers/esql/EsqlHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import co.elastic.clients.elasticsearch.esql.ElasticsearchEsqlAsyncClient;
2424
import co.elastic.clients.elasticsearch.esql.ElasticsearchEsqlClient;
2525
import co.elastic.clients.elasticsearch.esql.QueryRequest;
26+
import co.elastic.clients.elasticsearch.esql.query.EsqlFormat;
2627
import co.elastic.clients.json.JsonData;
2728
import co.elastic.clients.transport.endpoints.BinaryResponse;
2829

@@ -81,7 +82,7 @@ private static <T> CompletableFuture<T> doQueryAsync(
8182

8283
private static QueryRequest buildRequest(EsqlAdapter<?> adapter, String query, Object... params) {
8384
return QueryRequest.of(esql -> esql
84-
.format(adapter.format())
85+
.format(EsqlFormat._DESERIALIZER.parse(adapter.format()))
8586
.columnar(adapter.columnar())
8687
.query(query)
8788
.params(asFieldValues(params))
@@ -91,7 +92,7 @@ private static QueryRequest buildRequest(EsqlAdapter<?> adapter, String query, O
9192
private static QueryRequest buildRequest(EsqlAdapter<?> adapter, QueryRequest request) {
9293
return QueryRequest.of(q -> q
9394
// Set/override format and columnar
94-
.format(adapter.format())
95+
.format(EsqlFormat._DESERIALIZER.parse(adapter.format()))
9596
.columnar(adapter.columnar())
9697

9798
.delimiter(request.delimiter())

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

Lines changed: 116 additions & 108 deletions
Large diffs are not rendered by default.

java-client/src/main/java/co/elastic/clients/elasticsearch/esql/QueryRequest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import co.elastic.clients.elasticsearch._types.FieldValue;
2424
import co.elastic.clients.elasticsearch._types.RequestBase;
2525
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
26+
import co.elastic.clients.elasticsearch.esql.query.EsqlFormat;
2627
import co.elastic.clients.json.JsonpDeserializable;
2728
import co.elastic.clients.json.JsonpDeserializer;
2829
import co.elastic.clients.json.JsonpMapper;
@@ -81,7 +82,7 @@ public class QueryRequest extends RequestBase implements JsonpSerializable {
8182
private final Query filter;
8283

8384
@Nullable
84-
private final String format;
85+
private final EsqlFormat format;
8586

8687
@Nullable
8788
private final String locale;
@@ -149,7 +150,7 @@ public final Query filter() {
149150
* API name: {@code format}
150151
*/
151152
@Nullable
152-
public final String format() {
153+
public final EsqlFormat format() {
153154
return this.format;
154155
}
155156

@@ -240,7 +241,7 @@ public static class Builder extends RequestBase.AbstractBuilder<Builder> impleme
240241
private Query filter;
241242

242243
@Nullable
243-
private String format;
244+
private EsqlFormat format;
244245

245246
@Nullable
246247
private String locale;
@@ -300,7 +301,7 @@ public final Builder filter(Function<Query.Builder, ObjectBuilder<Query>> fn) {
300301
* <p>
301302
* API name: {@code format}
302303
*/
303-
public final Builder format(@Nullable String value) {
304+
public final Builder format(@Nullable EsqlFormat value) {
304305
this.format = value;
305306
return this;
306307
}
@@ -433,7 +434,7 @@ protected static void setupQueryRequestDeserializer(ObjectDeserializer<QueryRequ
433434
params.put("delimiter", request.delimiter);
434435
}
435436
if (request.format != null) {
436-
params.put("format", request.format);
437+
params.put("format", request.format.jsonValue());
437438
}
438439
return params;
439440

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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.elasticsearch.esql.query;
21+
22+
import co.elastic.clients.json.JsonEnum;
23+
import co.elastic.clients.json.JsonpDeserializable;
24+
import co.elastic.clients.json.JsonpDeserializer;
25+
26+
//----------------------------------------------------------------
27+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
28+
//----------------------------------------------------------------
29+
//
30+
// This code is generated from the Elasticsearch API specification
31+
// at https://github.com/elastic/elasticsearch-specification
32+
//
33+
// Manual updates to this file will be lost when the code is
34+
// re-generated.
35+
//
36+
// If you find a property that is missing or wrongly typed, please
37+
// open an issue or a PR on the API specification repository.
38+
//
39+
//----------------------------------------------------------------
40+
41+
/**
42+
*
43+
* @see <a href="../../doc-files/api-spec.html#esql.query.EsqlFormat">API
44+
* specification</a>
45+
*/
46+
@JsonpDeserializable
47+
public enum EsqlFormat implements JsonEnum {
48+
Csv("csv"),
49+
50+
Json("json"),
51+
52+
Tsv("tsv"),
53+
54+
Txt("txt"),
55+
56+
Yaml("yaml"),
57+
58+
Cbor("cbor"),
59+
60+
Smile("smile"),
61+
62+
Arrow("arrow"),
63+
64+
;
65+
66+
private final String jsonValue;
67+
68+
EsqlFormat(String jsonValue) {
69+
this.jsonValue = jsonValue;
70+
}
71+
72+
public String jsonValue() {
73+
return this.jsonValue;
74+
}
75+
76+
public static final JsonEnum.Deserializer<EsqlFormat> _DESERIALIZER = new JsonEnum.Deserializer<>(
77+
EsqlFormat.values());
78+
}

java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/Processor.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public enum Kind implements JsonEnum {
124124

125125
Pipeline("pipeline"),
126126

127+
Redact("redact"),
128+
127129
Remove("remove"),
128130

129131
Rename("rename"),
@@ -626,6 +628,23 @@ public PipelineProcessor pipeline() {
626628
return TaggedUnionUtils.get(this, Kind.Pipeline);
627629
}
628630

631+
/**
632+
* Is this variant instance of kind {@code redact}?
633+
*/
634+
public boolean isRedact() {
635+
return _kind == Kind.Redact;
636+
}
637+
638+
/**
639+
* Get the {@code redact} variant value.
640+
*
641+
* @throws IllegalStateException
642+
* if the current variant is not of the {@code redact} kind.
643+
*/
644+
public RedactProcessor redact() {
645+
return TaggedUnionUtils.get(this, Kind.Redact);
646+
}
647+
629648
/**
630649
* Is this variant instance of kind {@code remove}?
631650
*/
@@ -1167,6 +1186,16 @@ public ObjectBuilder<Processor> pipeline(
11671186
return this.pipeline(fn.apply(new PipelineProcessor.Builder()).build());
11681187
}
11691188

1189+
public ObjectBuilder<Processor> redact(RedactProcessor v) {
1190+
this._kind = Kind.Redact;
1191+
this._value = v;
1192+
return this;
1193+
}
1194+
1195+
public ObjectBuilder<Processor> redact(Function<RedactProcessor.Builder, ObjectBuilder<RedactProcessor>> fn) {
1196+
return this.redact(fn.apply(new RedactProcessor.Builder()).build());
1197+
}
1198+
11701199
public ObjectBuilder<Processor> remove(RemoveProcessor v) {
11711200
this._kind = Kind.Remove;
11721201
this._value = v;
@@ -1353,6 +1382,7 @@ protected static void setupProcessorDeserializer(ObjectDeserializer<Builder> op)
13531382
op.add(Builder::kv, KeyValueProcessor._DESERIALIZER, "kv");
13541383
op.add(Builder::lowercase, LowercaseProcessor._DESERIALIZER, "lowercase");
13551384
op.add(Builder::pipeline, PipelineProcessor._DESERIALIZER, "pipeline");
1385+
op.add(Builder::redact, RedactProcessor._DESERIALIZER, "redact");
13561386
op.add(Builder::remove, RemoveProcessor._DESERIALIZER, "remove");
13571387
op.add(Builder::rename, RenameProcessor._DESERIALIZER, "rename");
13581388
op.add(Builder::reroute, RerouteProcessor._DESERIALIZER, "reroute");

java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/ProcessorBuilders.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,24 @@ public static Processor pipeline(Function<PipelineProcessor.Builder, ObjectBuild
495495
return builder.build();
496496
}
497497

498+
/**
499+
* Creates a builder for the {@link RedactProcessor redact} {@code Processor}
500+
* variant.
501+
*/
502+
public static RedactProcessor.Builder redact() {
503+
return new RedactProcessor.Builder();
504+
}
505+
506+
/**
507+
* Creates a Processor of the {@link RedactProcessor redact} {@code Processor}
508+
* variant.
509+
*/
510+
public static Processor redact(Function<RedactProcessor.Builder, ObjectBuilder<RedactProcessor>> fn) {
511+
Processor.Builder builder = new Processor.Builder();
512+
builder.redact(fn.apply(new RedactProcessor.Builder()).build());
513+
return builder.build();
514+
}
515+
498516
/**
499517
* Creates a builder for the {@link RemoveProcessor remove} {@code Processor}
500518
* variant.

0 commit comments

Comments
 (0)