Skip to content

Commit 5546c8a

Browse files
committed
[codegen] update to latest spec and generator
1 parent 400fc2e commit 5546c8a

File tree

199 files changed

+22993
-2258
lines changed

Some content is hidden

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

199 files changed

+22993
-2258
lines changed

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

Lines changed: 16 additions & 7 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,14 +347,14 @@ 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");
345354
op.add(Builder::options, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()),
346355
"options");
347356

348-
op.shortcutProperty("source");
357+
op.shortcutProperty("source", true);
349358

350359
}
351360

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
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._types;
21+
22+
import co.elastic.clients.elasticsearch.core.search.SearchRequestBody;
23+
import co.elastic.clients.json.JsonpDeserializable;
24+
import co.elastic.clients.json.JsonpDeserializer;
25+
import co.elastic.clients.json.JsonpMapper;
26+
import co.elastic.clients.json.JsonpSerializable;
27+
import co.elastic.clients.json.JsonpUtils;
28+
import co.elastic.clients.json.ObjectDeserializer;
29+
import co.elastic.clients.json.UnionDeserializer;
30+
import co.elastic.clients.util.ApiTypeHelper;
31+
import co.elastic.clients.util.ObjectBuilder;
32+
import co.elastic.clients.util.ObjectBuilderBase;
33+
import co.elastic.clients.util.TaggedUnion;
34+
import co.elastic.clients.util.TaggedUnionUtils;
35+
import jakarta.json.stream.JsonGenerator;
36+
import java.lang.Object;
37+
import java.lang.String;
38+
import java.util.Objects;
39+
import java.util.function.Function;
40+
import javax.annotation.Nullable;
41+
42+
//----------------------------------------------------------------
43+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
44+
//----------------------------------------------------------------
45+
//
46+
// This code is generated from the Elasticsearch API specification
47+
// at https://github.com/elastic/elasticsearch-specification
48+
//
49+
// Manual updates to this file will be lost when the code is
50+
// re-generated.
51+
//
52+
// If you find a property that is missing or wrongly typed, please
53+
// open an issue or a PR on the API specification repository.
54+
//
55+
//----------------------------------------------------------------
56+
57+
// typedef: _types.ScriptSource
58+
59+
/**
60+
*
61+
* @see <a href="../doc-files/api-spec.html#_types.ScriptSource">API
62+
* specification</a>
63+
*/
64+
@JsonpDeserializable
65+
public class ScriptSource implements TaggedUnion<ScriptSource.Kind, Object>, JsonpSerializable {
66+
67+
public enum Kind {
68+
ScriptTemplate, ScriptString
69+
70+
}
71+
72+
private final Kind _kind;
73+
private final Object _value;
74+
75+
@Override
76+
public final Kind _kind() {
77+
return _kind;
78+
}
79+
80+
@Override
81+
public final Object _get() {
82+
return _value;
83+
}
84+
85+
private ScriptSource(Kind kind, Object value) {
86+
this._kind = kind;
87+
this._value = value;
88+
}
89+
90+
private ScriptSource(Builder builder) {
91+
92+
this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
93+
this._value = ApiTypeHelper.requireNonNull(builder._value, builder, "<variant value>");
94+
95+
}
96+
97+
public static ScriptSource of(Function<Builder, ObjectBuilder<ScriptSource>> fn) {
98+
return fn.apply(new Builder()).build();
99+
}
100+
101+
/**
102+
* Is this variant instance of kind {@code script_template}?
103+
*/
104+
public boolean isScriptTemplate() {
105+
return _kind == Kind.ScriptTemplate;
106+
}
107+
108+
/**
109+
* Get the {@code script_template} variant value.
110+
*
111+
* @throws IllegalStateException
112+
* if the current variant is not of the {@code script_template}
113+
* kind.
114+
*/
115+
public SearchRequestBody scriptTemplate() {
116+
return TaggedUnionUtils.get(this, Kind.ScriptTemplate);
117+
}
118+
119+
/**
120+
* Is this variant instance of kind {@code script_string}?
121+
*/
122+
public boolean isScriptString() {
123+
return _kind == Kind.ScriptString;
124+
}
125+
126+
/**
127+
* Get the {@code script_string} variant value.
128+
*
129+
* @throws IllegalStateException
130+
* if the current variant is not of the {@code script_string} kind.
131+
*/
132+
public String scriptString() {
133+
return TaggedUnionUtils.get(this, Kind.ScriptString);
134+
}
135+
136+
@Override
137+
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
138+
if (_value instanceof JsonpSerializable) {
139+
((JsonpSerializable) _value).serialize(generator, mapper);
140+
} else {
141+
switch (_kind) {
142+
case ScriptString :
143+
generator.write(((String) this._value));
144+
145+
break;
146+
}
147+
}
148+
149+
}
150+
151+
@Override
152+
public String toString() {
153+
return JsonpUtils.toString(this);
154+
}
155+
156+
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<ScriptSource> {
157+
private Kind _kind;
158+
private Object _value;
159+
160+
public ObjectBuilder<ScriptSource> scriptTemplate(SearchRequestBody v) {
161+
this._kind = Kind.ScriptTemplate;
162+
this._value = v;
163+
return this;
164+
}
165+
166+
public ObjectBuilder<ScriptSource> scriptTemplate(
167+
Function<SearchRequestBody.Builder, ObjectBuilder<SearchRequestBody>> fn) {
168+
return this.scriptTemplate(fn.apply(new SearchRequestBody.Builder()).build());
169+
}
170+
171+
public ObjectBuilder<ScriptSource> scriptString(String v) {
172+
this._kind = Kind.ScriptString;
173+
this._value = v;
174+
return this;
175+
}
176+
177+
public ScriptSource build() {
178+
_checkSingleUse();
179+
return new ScriptSource(this);
180+
}
181+
182+
}
183+
184+
private static JsonpDeserializer<ScriptSource> buildScriptSourceDeserializer() {
185+
return new UnionDeserializer.Builder<ScriptSource, Kind, Object>(ScriptSource::new, false)
186+
.addMember(Kind.ScriptTemplate, SearchRequestBody._DESERIALIZER)
187+
.addMember(Kind.ScriptString, JsonpDeserializer.stringDeserializer()).build();
188+
}
189+
190+
public static final JsonpDeserializer<ScriptSource> _DESERIALIZER = JsonpDeserializer
191+
.lazy(ScriptSource::buildScriptSourceDeserializer);
192+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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._types;
21+
22+
import co.elastic.clients.elasticsearch.core.search.SearchRequestBody;
23+
import co.elastic.clients.util.ObjectBuilder;
24+
import java.util.function.Function;
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+
* Builders for {@link ScriptSource} variants.
43+
* <p>
44+
* Variants <code>script_string</code> are not available here as they don't have
45+
* a dedicated class. Use {@link ScriptSource}'s builder for these.
46+
*
47+
*/
48+
public class ScriptSourceBuilders {
49+
private ScriptSourceBuilders() {
50+
}
51+
52+
/**
53+
* Creates a builder for the {@link SearchRequestBody script_template}
54+
* {@code ScriptSource} variant.
55+
*/
56+
public static SearchRequestBody.Builder scriptTemplate() {
57+
return new SearchRequestBody.Builder();
58+
}
59+
60+
}

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class ScriptTransform implements TransformVariant, JsonpSerializable {
6767
private final Map<String, JsonData> params;
6868

6969
@Nullable
70-
private final String source;
70+
private final ScriptSource source;
7171

7272
@Nullable
7373
private final String id;
@@ -114,7 +114,7 @@ public final Map<String, JsonData> params() {
114114
* API name: {@code source}
115115
*/
116116
@Nullable
117-
public final String source() {
117+
public final ScriptSource source() {
118118
return this.source;
119119
}
120120

@@ -155,7 +155,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
155155
}
156156
if (this.source != null) {
157157
generator.writeKey("source");
158-
generator.write(this.source);
158+
this.source.serialize(generator, mapper);
159159

160160
}
161161
if (this.id != null) {
@@ -185,7 +185,7 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder> implement
185185
private Map<String, JsonData> params;
186186

187187
@Nullable
188-
private String source;
188+
private ScriptSource source;
189189

190190
@Nullable
191191
private String id;
@@ -221,11 +221,18 @@ public final Builder params(String key, JsonData value) {
221221
/**
222222
* API name: {@code source}
223223
*/
224-
public final Builder source(@Nullable String value) {
224+
public final Builder source(@Nullable ScriptSource value) {
225225
this.source = value;
226226
return this;
227227
}
228228

229+
/**
230+
* API name: {@code source}
231+
*/
232+
public final Builder source(Function<ScriptSource.Builder, ObjectBuilder<ScriptSource>> fn) {
233+
return this.source(fn.apply(new ScriptSource.Builder()).build());
234+
}
235+
229236
/**
230237
* API name: {@code id}
231238
*/
@@ -264,7 +271,7 @@ protected static void setupScriptTransformDeserializer(ObjectDeserializer<Script
264271

265272
op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang");
266273
op.add(Builder::params, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "params");
267-
op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source");
274+
op.add(Builder::source, ScriptSource._DESERIALIZER, "source");
268275
op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id");
269276

270277
}

0 commit comments

Comments
 (0)