Skip to content

Commit 6263592

Browse files
authored
Add geohex_grid aggregate (#432)
1 parent 866cf9d commit 6263592

File tree

5 files changed

+403
-117
lines changed

5 files changed

+403
-117
lines changed

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

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

108108
GeohashGrid("geohash_grid"),
109109

110+
GeohexGrid("geohex_grid"),
111+
110112
GeoLine("geo_line"),
111113

112114
GeotileGrid("geotile_grid"),
@@ -621,6 +623,23 @@ public GeoHashGridAggregate geohashGrid() {
621623
return TaggedUnionUtils.get(this, Kind.GeohashGrid);
622624
}
623625

626+
/**
627+
* Is this variant instance of kind {@code geohex_grid}?
628+
*/
629+
public boolean isGeohexGrid() {
630+
return _kind == Kind.GeohexGrid;
631+
}
632+
633+
/**
634+
* Get the {@code geohex_grid} variant value.
635+
*
636+
* @throws IllegalStateException
637+
* if the current variant is not of the {@code geohex_grid} kind.
638+
*/
639+
public GeoHexGridAggregate geohexGrid() {
640+
return TaggedUnionUtils.get(this, Kind.GeohexGrid);
641+
}
642+
624643
/**
625644
* Is this variant instance of kind {@code geo_line}?
626645
*/
@@ -1687,6 +1706,17 @@ public ObjectBuilder<Aggregate> geohashGrid(
16871706
return this.geohashGrid(fn.apply(new GeoHashGridAggregate.Builder()).build());
16881707
}
16891708

1709+
public ObjectBuilder<Aggregate> geohexGrid(GeoHexGridAggregate v) {
1710+
this._kind = Kind.GeohexGrid;
1711+
this._value = v;
1712+
return this;
1713+
}
1714+
1715+
public ObjectBuilder<Aggregate> geohexGrid(
1716+
Function<GeoHexGridAggregate.Builder, ObjectBuilder<GeoHexGridAggregate>> fn) {
1717+
return this.geohexGrid(fn.apply(new GeoHexGridAggregate.Builder()).build());
1718+
}
1719+
16901720
public ObjectBuilder<Aggregate> geoLine(GeoLineAggregate v) {
16911721
this._kind = Kind.GeoLine;
16921722
this._value = v;
@@ -2231,6 +2261,7 @@ public Aggregate build() {
22312261
deserializers.put("geo_centroid", GeoCentroidAggregate._DESERIALIZER);
22322262
deserializers.put("geo_distance", GeoDistanceAggregate._DESERIALIZER);
22332263
deserializers.put("geohash_grid", GeoHashGridAggregate._DESERIALIZER);
2264+
deserializers.put("geohex_grid", GeoHexGridAggregate._DESERIALIZER);
22342265
deserializers.put("geo_line", GeoLineAggregate._DESERIALIZER);
22352266
deserializers.put("geotile_grid", GeoTileGridAggregate._DESERIALIZER);
22362267
deserializers.put("global", GlobalAggregate._DESERIALIZER);

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,24 @@ public static Aggregate geohashGrid(
421421
return builder.build();
422422
}
423423

424+
/**
425+
* Creates a builder for the {@link GeoHexGridAggregate geohex_grid}
426+
* {@code Aggregate} variant.
427+
*/
428+
public static GeoHexGridAggregate.Builder geohexGrid() {
429+
return new GeoHexGridAggregate.Builder();
430+
}
431+
432+
/**
433+
* Creates a Aggregate of the {@link GeoHexGridAggregate geohex_grid}
434+
* {@code Aggregate} variant.
435+
*/
436+
public static Aggregate geohexGrid(Function<GeoHexGridAggregate.Builder, ObjectBuilder<GeoHexGridAggregate>> fn) {
437+
Aggregate.Builder builder = new Aggregate.Builder();
438+
builder.geohexGrid(fn.apply(new GeoHexGridAggregate.Builder()).build());
439+
return builder.build();
440+
}
441+
424442
/**
425443
* Creates a builder for the {@link GeoLineAggregate geo_line} {@code Aggregate}
426444
* variant.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
//----------------------------------------------------
21+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
22+
//----------------------------------------------------
23+
24+
package co.elastic.clients.elasticsearch._types.aggregations;
25+
26+
import co.elastic.clients.json.JsonpDeserializable;
27+
import co.elastic.clients.json.JsonpDeserializer;
28+
import co.elastic.clients.json.ObjectBuilderDeserializer;
29+
import co.elastic.clients.json.ObjectDeserializer;
30+
import co.elastic.clients.util.ObjectBuilder;
31+
import jakarta.json.stream.JsonGenerator;
32+
import java.util.Objects;
33+
import java.util.function.Function;
34+
35+
// typedef: _types.aggregations.GeoHexGridAggregate
36+
37+
/**
38+
*
39+
* @see <a href=
40+
* "../../doc-files/api-spec.html#_types.aggregations.GeoHexGridAggregate">API
41+
* specification</a>
42+
*/
43+
@JsonpDeserializable
44+
public class GeoHexGridAggregate extends MultiBucketAggregateBase<GeoHexGridBucket> implements AggregateVariant {
45+
// ---------------------------------------------------------------------------------------------
46+
47+
private GeoHexGridAggregate(Builder builder) {
48+
super(builder);
49+
50+
}
51+
52+
public static GeoHexGridAggregate of(Function<Builder, ObjectBuilder<GeoHexGridAggregate>> fn) {
53+
return fn.apply(new Builder()).build();
54+
}
55+
56+
/**
57+
* Aggregate variant kind.
58+
*/
59+
@Override
60+
public Aggregate.Kind _aggregateKind() {
61+
return Aggregate.Kind.GeohexGrid;
62+
}
63+
64+
// ---------------------------------------------------------------------------------------------
65+
66+
/**
67+
* Builder for {@link GeoHexGridAggregate}.
68+
*/
69+
70+
public static class Builder extends MultiBucketAggregateBase.AbstractBuilder<GeoHexGridBucket, Builder>
71+
implements
72+
ObjectBuilder<GeoHexGridAggregate> {
73+
@Override
74+
protected Builder self() {
75+
return this;
76+
}
77+
78+
/**
79+
* Builds a {@link GeoHexGridAggregate}.
80+
*
81+
* @throws NullPointerException
82+
* if some of the required fields are null.
83+
*/
84+
public GeoHexGridAggregate build() {
85+
_checkSingleUse();
86+
super.tBucketSerializer(null);
87+
88+
return new GeoHexGridAggregate(this);
89+
}
90+
}
91+
92+
// ---------------------------------------------------------------------------------------------
93+
94+
/**
95+
* Json deserializer for {@link GeoHexGridAggregate}
96+
*/
97+
public static final JsonpDeserializer<GeoHexGridAggregate> _DESERIALIZER = ObjectBuilderDeserializer
98+
.lazy(Builder::new, GeoHexGridAggregate::setupGeoHexGridAggregateDeserializer);
99+
100+
protected static void setupGeoHexGridAggregateDeserializer(ObjectDeserializer<GeoHexGridAggregate.Builder> op) {
101+
MultiBucketAggregateBase.setupMultiBucketAggregateBaseDeserializer(op, GeoHexGridBucket._DESERIALIZER);
102+
103+
}
104+
105+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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+
//----------------------------------------------------
21+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
22+
//----------------------------------------------------
23+
24+
package co.elastic.clients.elasticsearch._types.aggregations;
25+
26+
import co.elastic.clients.json.JsonpDeserializable;
27+
import co.elastic.clients.json.JsonpDeserializer;
28+
import co.elastic.clients.json.JsonpMapper;
29+
import co.elastic.clients.json.ObjectBuilderDeserializer;
30+
import co.elastic.clients.json.ObjectDeserializer;
31+
import co.elastic.clients.util.ApiTypeHelper;
32+
import co.elastic.clients.util.ObjectBuilder;
33+
import jakarta.json.stream.JsonGenerator;
34+
import java.lang.String;
35+
import java.util.Objects;
36+
import java.util.function.Function;
37+
import javax.annotation.Nullable;
38+
39+
// typedef: _types.aggregations.GeoHexGridBucket
40+
41+
/**
42+
*
43+
* @see <a href=
44+
* "../../doc-files/api-spec.html#_types.aggregations.GeoHexGridBucket">API
45+
* specification</a>
46+
*/
47+
@JsonpDeserializable
48+
public class GeoHexGridBucket extends MultiBucketBase {
49+
private final String key;
50+
51+
// ---------------------------------------------------------------------------------------------
52+
53+
private GeoHexGridBucket(Builder builder) {
54+
super(builder);
55+
56+
this.key = ApiTypeHelper.requireNonNull(builder.key, this, "key");
57+
58+
}
59+
60+
public static GeoHexGridBucket of(Function<Builder, ObjectBuilder<GeoHexGridBucket>> fn) {
61+
return fn.apply(new Builder()).build();
62+
}
63+
64+
/**
65+
* Required - API name: {@code key}
66+
*/
67+
public final String key() {
68+
return this.key;
69+
}
70+
71+
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
72+
73+
super.serializeInternal(generator, mapper);
74+
generator.writeKey("key");
75+
generator.write(this.key);
76+
77+
}
78+
79+
// ---------------------------------------------------------------------------------------------
80+
81+
/**
82+
* Builder for {@link GeoHexGridBucket}.
83+
*/
84+
85+
public static class Builder extends MultiBucketBase.AbstractBuilder<Builder>
86+
implements
87+
ObjectBuilder<GeoHexGridBucket> {
88+
private String key;
89+
90+
/**
91+
* Required - API name: {@code key}
92+
*/
93+
public final Builder key(String value) {
94+
this.key = value;
95+
return this;
96+
}
97+
98+
@Override
99+
protected Builder self() {
100+
return this;
101+
}
102+
103+
/**
104+
* Builds a {@link GeoHexGridBucket}.
105+
*
106+
* @throws NullPointerException
107+
* if some of the required fields are null.
108+
*/
109+
public GeoHexGridBucket build() {
110+
_checkSingleUse();
111+
112+
return new GeoHexGridBucket(this);
113+
}
114+
}
115+
116+
// ---------------------------------------------------------------------------------------------
117+
118+
/**
119+
* Json deserializer for {@link GeoHexGridBucket}
120+
*/
121+
public static final JsonpDeserializer<GeoHexGridBucket> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new,
122+
GeoHexGridBucket::setupGeoHexGridBucketDeserializer);
123+
124+
protected static void setupGeoHexGridBucketDeserializer(ObjectDeserializer<GeoHexGridBucket.Builder> op) {
125+
MultiBucketBase.setupMultiBucketBaseDeserializer(op);
126+
op.add(Builder::key, JsonpDeserializer.stringDeserializer(), "key");
127+
128+
}
129+
130+
}

0 commit comments

Comments
 (0)