Skip to content

Commit b5574fa

Browse files
committed
[codegen] update to latest spec
1 parent 99ff263 commit b5574fa

File tree

10 files changed

+525
-94
lines changed

10 files changed

+525
-94
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
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.query_dsl;
21+
22+
import co.elastic.clients.json.JsonEnum;
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.ObjectBuilderDeserializer;
29+
import co.elastic.clients.json.ObjectDeserializer;
30+
import co.elastic.clients.util.ApiTypeHelper;
31+
import co.elastic.clients.util.ObjectBuilder;
32+
import co.elastic.clients.util.TaggedUnion;
33+
import co.elastic.clients.util.TaggedUnionUtils;
34+
import jakarta.json.stream.JsonGenerator;
35+
import java.lang.Object;
36+
import java.lang.String;
37+
import java.util.Objects;
38+
import java.util.function.Function;
39+
import javax.annotation.Nullable;
40+
41+
//----------------------------------------------------------------
42+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
43+
//----------------------------------------------------------------
44+
//
45+
// This code is generated from the Elasticsearch API specification
46+
// at https://github.com/elastic/elasticsearch-specification
47+
//
48+
// Manual updates to this file will be lost when the code is
49+
// re-generated.
50+
//
51+
// If you find a property that is missing or wrongly typed, please
52+
// open an issue or a PR on the API specification repository.
53+
//
54+
//----------------------------------------------------------------
55+
56+
// typedef: _types.query_dsl.GeoGridQuery
57+
58+
/**
59+
*
60+
* @see <a href=
61+
* "../../doc-files/api-spec.html#_types.query_dsl.GeoGridQuery">API
62+
* specification</a>
63+
*/
64+
@JsonpDeserializable
65+
public class GeoGridQuery extends QueryBase
66+
implements
67+
TaggedUnion<GeoGridQuery.Kind, Object>,
68+
QueryVariant,
69+
JsonpSerializable {
70+
71+
/**
72+
* {@link GeoGridQuery} variant kinds.
73+
*
74+
* @see <a href=
75+
* "../../doc-files/api-spec.html#_types.query_dsl.GeoGridQuery">API
76+
* specification</a>
77+
*/
78+
79+
public enum Kind implements JsonEnum {
80+
Geogrid("geogrid"),
81+
82+
Geohash("geohash"),
83+
84+
Geohex("geohex"),
85+
86+
;
87+
88+
private final String jsonValue;
89+
90+
Kind(String jsonValue) {
91+
this.jsonValue = jsonValue;
92+
}
93+
94+
public String jsonValue() {
95+
return this.jsonValue;
96+
}
97+
98+
}
99+
100+
/**
101+
* Query variant kind.
102+
*/
103+
@Override
104+
public Query.Kind _queryKind() {
105+
return Query.Kind.GeoGrid;
106+
}
107+
108+
private final Kind _kind;
109+
private final Object _value;
110+
111+
@Override
112+
public final Kind _kind() {
113+
return _kind;
114+
}
115+
116+
@Override
117+
public final Object _get() {
118+
return _value;
119+
}
120+
121+
// Single key dictionary
122+
private final String field;
123+
124+
private GeoGridQuery(Builder builder) {
125+
super(builder);
126+
this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field");
127+
128+
this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
129+
this._value = ApiTypeHelper.requireNonNull(builder._value, builder, "<variant value>");
130+
131+
}
132+
133+
public static GeoGridQuery of(Function<Builder, ObjectBuilder<GeoGridQuery>> fn) {
134+
return fn.apply(new Builder()).build();
135+
}
136+
137+
/**
138+
* Required - The target field
139+
*/
140+
public final String field() {
141+
return this.field;
142+
}
143+
144+
/**
145+
* Is this variant instance of kind {@code geogrid}?
146+
*/
147+
public boolean isGeogrid() {
148+
return _kind == Kind.Geogrid;
149+
}
150+
151+
/**
152+
* Get the {@code geogrid} variant value.
153+
*
154+
* @throws IllegalStateException
155+
* if the current variant is not of the {@code geogrid} kind.
156+
*/
157+
public String geogrid() {
158+
return TaggedUnionUtils.get(this, Kind.Geogrid);
159+
}
160+
161+
/**
162+
* Is this variant instance of kind {@code geohash}?
163+
*/
164+
public boolean isGeohash() {
165+
return _kind == Kind.Geohash;
166+
}
167+
168+
/**
169+
* Get the {@code geohash} variant value.
170+
*
171+
* @throws IllegalStateException
172+
* if the current variant is not of the {@code geohash} kind.
173+
*/
174+
public String geohash() {
175+
return TaggedUnionUtils.get(this, Kind.Geohash);
176+
}
177+
178+
/**
179+
* Is this variant instance of kind {@code geohex}?
180+
*/
181+
public boolean isGeohex() {
182+
return _kind == Kind.Geohex;
183+
}
184+
185+
/**
186+
* Get the {@code geohex} variant value.
187+
*
188+
* @throws IllegalStateException
189+
* if the current variant is not of the {@code geohex} kind.
190+
*/
191+
public String geohex() {
192+
return TaggedUnionUtils.get(this, Kind.Geohex);
193+
}
194+
195+
@Override
196+
@SuppressWarnings("unchecked")
197+
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
198+
199+
generator.writeStartObject();
200+
generator.writeStartObject(this.field);
201+
202+
super.serializeInternal(generator, mapper);
203+
204+
generator.writeKey(_kind.jsonValue());
205+
if (_value instanceof JsonpSerializable) {
206+
((JsonpSerializable) _value).serialize(generator, mapper);
207+
} else {
208+
switch (_kind) {
209+
case Geogrid :
210+
generator.write(((String) this._value));
211+
212+
break;
213+
case Geohash :
214+
generator.write(((String) this._value));
215+
216+
break;
217+
case Geohex :
218+
generator.write(((String) this._value));
219+
220+
break;
221+
}
222+
}
223+
224+
generator.writeEnd();
225+
226+
generator.writeEnd();
227+
228+
}
229+
230+
@Override
231+
public String toString() {
232+
return JsonpUtils.toString(this);
233+
}
234+
235+
public static class Builder extends QueryBase.AbstractBuilder<Builder> implements ObjectBuilder<GeoGridQuery> {
236+
private Kind _kind;
237+
private Object _value;
238+
239+
private String field;
240+
241+
/**
242+
* Required - The target field
243+
*/
244+
public final Builder field(String value) {
245+
this.field = value;
246+
return this;
247+
}
248+
249+
@Override
250+
protected Builder self() {
251+
return this;
252+
}
253+
public ObjectBuilder<GeoGridQuery> geogrid(String v) {
254+
this._kind = Kind.Geogrid;
255+
this._value = v;
256+
return this;
257+
}
258+
259+
public ObjectBuilder<GeoGridQuery> geohash(String v) {
260+
this._kind = Kind.Geohash;
261+
this._value = v;
262+
return this;
263+
}
264+
265+
public ObjectBuilder<GeoGridQuery> geohex(String v) {
266+
this._kind = Kind.Geohex;
267+
this._value = v;
268+
return this;
269+
}
270+
271+
public GeoGridQuery build() {
272+
_checkSingleUse();
273+
return new GeoGridQuery(this);
274+
}
275+
276+
}
277+
278+
protected static void setupGeoGridQueryDeserializer(ObjectDeserializer<Builder> op) {
279+
QueryBase.setupQueryBaseDeserializer(op);
280+
op.add(Builder::geogrid, JsonpDeserializer.stringDeserializer(), "geogrid");
281+
op.add(Builder::geohash, JsonpDeserializer.stringDeserializer(), "geohash");
282+
op.add(Builder::geohex, JsonpDeserializer.stringDeserializer(), "geohex");
283+
284+
op.setKey(Builder::field, JsonpDeserializer.stringDeserializer());
285+
286+
}
287+
288+
public static final JsonpDeserializer<GeoGridQuery> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new,
289+
GeoGridQuery::setupGeoGridQueryDeserializer, Builder::build);
290+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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.query_dsl;
21+
22+
import co.elastic.clients.util.ObjectBuilder;
23+
import java.util.function.Function;
24+
25+
//----------------------------------------------------------------
26+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
27+
//----------------------------------------------------------------
28+
//
29+
// This code is generated from the Elasticsearch API specification
30+
// at https://github.com/elastic/elasticsearch-specification
31+
//
32+
// Manual updates to this file will be lost when the code is
33+
// re-generated.
34+
//
35+
// If you find a property that is missing or wrongly typed, please
36+
// open an issue or a PR on the API specification repository.
37+
//
38+
//----------------------------------------------------------------
39+
40+
/**
41+
* Builders for {@link GeoGridQuery} variants.
42+
* <p>
43+
* Variants <code>geogrid</code>, <code>geohash</code>, <code>geohex</code> are
44+
* not available here as they don't have a dedicated class. Use
45+
* {@link GeoGridQuery}'s builder for these.
46+
*
47+
*/
48+
public class GeoGridQueryBuilders {
49+
private GeoGridQueryBuilders() {
50+
}
51+
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.query_dsl;
21+
22+
//----------------------------------------------------------------
23+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
24+
//----------------------------------------------------------------
25+
//
26+
// This code is generated from the Elasticsearch API specification
27+
// at https://github.com/elastic/elasticsearch-specification
28+
//
29+
// Manual updates to this file will be lost when the code is
30+
// re-generated.
31+
//
32+
// If you find a property that is missing or wrongly typed, please
33+
// open an issue or a PR on the API specification repository.
34+
//
35+
//----------------------------------------------------------------
36+
37+
/**
38+
* Base interface for {@link GeoGridQuery} variants.
39+
*/
40+
public interface GeoGridQueryVariant {
41+
42+
GeoGridQuery.Kind _geoGridQueryKind();
43+
44+
}

0 commit comments

Comments
 (0)