Skip to content

Add geohex_grid aggregate #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public enum Kind implements JsonEnum {

GeohashGrid("geohash_grid"),

GeohexGrid("geohex_grid"),

GeoLine("geo_line"),

GeotileGrid("geotile_grid"),
Expand Down Expand Up @@ -621,6 +623,23 @@ public GeoHashGridAggregate geohashGrid() {
return TaggedUnionUtils.get(this, Kind.GeohashGrid);
}

/**
* Is this variant instance of kind {@code geohex_grid}?
*/
public boolean isGeohexGrid() {
return _kind == Kind.GeohexGrid;
}

/**
* Get the {@code geohex_grid} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code geohex_grid} kind.
*/
public GeoHexGridAggregate geohexGrid() {
return TaggedUnionUtils.get(this, Kind.GeohexGrid);
}

/**
* Is this variant instance of kind {@code geo_line}?
*/
Expand Down Expand Up @@ -1687,6 +1706,17 @@ public ObjectBuilder<Aggregate> geohashGrid(
return this.geohashGrid(fn.apply(new GeoHashGridAggregate.Builder()).build());
}

public ObjectBuilder<Aggregate> geohexGrid(GeoHexGridAggregate v) {
this._kind = Kind.GeohexGrid;
this._value = v;
return this;
}

public ObjectBuilder<Aggregate> geohexGrid(
Function<GeoHexGridAggregate.Builder, ObjectBuilder<GeoHexGridAggregate>> fn) {
return this.geohexGrid(fn.apply(new GeoHexGridAggregate.Builder()).build());
}

public ObjectBuilder<Aggregate> geoLine(GeoLineAggregate v) {
this._kind = Kind.GeoLine;
this._value = v;
Expand Down Expand Up @@ -2231,6 +2261,7 @@ public Aggregate build() {
deserializers.put("geo_centroid", GeoCentroidAggregate._DESERIALIZER);
deserializers.put("geo_distance", GeoDistanceAggregate._DESERIALIZER);
deserializers.put("geohash_grid", GeoHashGridAggregate._DESERIALIZER);
deserializers.put("geohex_grid", GeoHexGridAggregate._DESERIALIZER);
deserializers.put("geo_line", GeoLineAggregate._DESERIALIZER);
deserializers.put("geotile_grid", GeoTileGridAggregate._DESERIALIZER);
deserializers.put("global", GlobalAggregate._DESERIALIZER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,24 @@ public static Aggregate geohashGrid(
return builder.build();
}

/**
* Creates a builder for the {@link GeoHexGridAggregate geohex_grid}
* {@code Aggregate} variant.
*/
public static GeoHexGridAggregate.Builder geohexGrid() {
return new GeoHexGridAggregate.Builder();
}

/**
* Creates a Aggregate of the {@link GeoHexGridAggregate geohex_grid}
* {@code Aggregate} variant.
*/
public static Aggregate geohexGrid(Function<GeoHexGridAggregate.Builder, ObjectBuilder<GeoHexGridAggregate>> fn) {
Aggregate.Builder builder = new Aggregate.Builder();
builder.geohexGrid(fn.apply(new GeoHexGridAggregate.Builder()).build());
return builder.build();
}

/**
* Creates a builder for the {@link GeoLineAggregate geo_line} {@code Aggregate}
* variant.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package co.elastic.clients.elasticsearch._types.aggregations;

import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.util.Objects;
import java.util.function.Function;

// typedef: _types.aggregations.GeoHexGridAggregate

/**
*
* @see <a href=
* "../../doc-files/api-spec.html#_types.aggregations.GeoHexGridAggregate">API
* specification</a>
*/
@JsonpDeserializable
public class GeoHexGridAggregate extends MultiBucketAggregateBase<GeoHexGridBucket> implements AggregateVariant {
// ---------------------------------------------------------------------------------------------

private GeoHexGridAggregate(Builder builder) {
super(builder);

}

public static GeoHexGridAggregate of(Function<Builder, ObjectBuilder<GeoHexGridAggregate>> fn) {
return fn.apply(new Builder()).build();
}

/**
* Aggregate variant kind.
*/
@Override
public Aggregate.Kind _aggregateKind() {
return Aggregate.Kind.GeohexGrid;
}

// ---------------------------------------------------------------------------------------------

/**
* Builder for {@link GeoHexGridAggregate}.
*/

public static class Builder extends MultiBucketAggregateBase.AbstractBuilder<GeoHexGridBucket, Builder>
implements
ObjectBuilder<GeoHexGridAggregate> {
@Override
protected Builder self() {
return this;
}

/**
* Builds a {@link GeoHexGridAggregate}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public GeoHexGridAggregate build() {
_checkSingleUse();
super.tBucketSerializer(null);

return new GeoHexGridAggregate(this);
}
}

// ---------------------------------------------------------------------------------------------

/**
* Json deserializer for {@link GeoHexGridAggregate}
*/
public static final JsonpDeserializer<GeoHexGridAggregate> _DESERIALIZER = ObjectBuilderDeserializer
.lazy(Builder::new, GeoHexGridAggregate::setupGeoHexGridAggregateDeserializer);

protected static void setupGeoHexGridAggregateDeserializer(ObjectDeserializer<GeoHexGridAggregate.Builder> op) {
MultiBucketAggregateBase.setupMultiBucketAggregateBaseDeserializer(op, GeoHexGridBucket._DESERIALIZER);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package co.elastic.clients.elasticsearch._types.aggregations;

import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.String;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

// typedef: _types.aggregations.GeoHexGridBucket

/**
*
* @see <a href=
* "../../doc-files/api-spec.html#_types.aggregations.GeoHexGridBucket">API
* specification</a>
*/
@JsonpDeserializable
public class GeoHexGridBucket extends MultiBucketBase {
private final String key;

// ---------------------------------------------------------------------------------------------

private GeoHexGridBucket(Builder builder) {
super(builder);

this.key = ApiTypeHelper.requireNonNull(builder.key, this, "key");

}

public static GeoHexGridBucket of(Function<Builder, ObjectBuilder<GeoHexGridBucket>> fn) {
return fn.apply(new Builder()).build();
}

/**
* Required - API name: {@code key}
*/
public final String key() {
return this.key;
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
generator.writeKey("key");
generator.write(this.key);

}

// ---------------------------------------------------------------------------------------------

/**
* Builder for {@link GeoHexGridBucket}.
*/

public static class Builder extends MultiBucketBase.AbstractBuilder<Builder>
implements
ObjectBuilder<GeoHexGridBucket> {
private String key;

/**
* Required - API name: {@code key}
*/
public final Builder key(String value) {
this.key = value;
return this;
}

@Override
protected Builder self() {
return this;
}

/**
* Builds a {@link GeoHexGridBucket}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public GeoHexGridBucket build() {
_checkSingleUse();

return new GeoHexGridBucket(this);
}
}

// ---------------------------------------------------------------------------------------------

/**
* Json deserializer for {@link GeoHexGridBucket}
*/
public static final JsonpDeserializer<GeoHexGridBucket> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new,
GeoHexGridBucket::setupGeoHexGridBucketDeserializer);

protected static void setupGeoHexGridBucketDeserializer(ObjectDeserializer<GeoHexGridBucket.Builder> op) {
MultiBucketBase.setupMultiBucketBaseDeserializer(op);
op.add(Builder::key, JsonpDeserializer.stringDeserializer(), "key");

}

}
Loading