Skip to content

Commit

Permalink
[codegen] update to latest spec
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta committed Sep 6, 2024
1 parent 0186134 commit be1f9aa
Show file tree
Hide file tree
Showing 52 changed files with 5,229 additions and 870 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import co.elastic.clients.util.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
Expand Down Expand Up @@ -72,11 +71,6 @@ public class NodeAttributes implements JsonpSerializable {

private final String transportAddress;

private final List<NodeRole> roles;

@Nullable
private final String externalId;

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

private NodeAttributes(Builder builder) {
Expand All @@ -86,8 +80,6 @@ private NodeAttributes(Builder builder) {
this.id = builder.id;
this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name");
this.transportAddress = ApiTypeHelper.requireNonNull(builder.transportAddress, this, "transportAddress");
this.roles = ApiTypeHelper.unmodifiable(builder.roles);
this.externalId = builder.externalId;

}

Expand Down Expand Up @@ -141,21 +133,6 @@ public final String transportAddress() {
return this.transportAddress;
}

/**
* API name: {@code roles}
*/
public final List<NodeRole> roles() {
return this.roles;
}

/**
* API name: {@code external_id}
*/
@Nullable
public final String externalId() {
return this.externalId;
}

/**
* Serialize this object to JSON.
*/
Expand Down Expand Up @@ -192,21 +169,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("transport_address");
generator.write(this.transportAddress);

if (ApiTypeHelper.isDefined(this.roles)) {
generator.writeKey("roles");
generator.writeStartArray();
for (NodeRole item0 : this.roles) {
item0.serialize(generator, mapper);
}
generator.writeEnd();

}
if (this.externalId != null) {
generator.writeKey("external_id");
generator.write(this.externalId);

}

}

@Override
Expand All @@ -232,12 +194,6 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder> implement

private String transportAddress;

@Nullable
private List<NodeRole> roles;

@Nullable
private String externalId;

/**
* Required - Lists node attributes.
* <p>
Expand Down Expand Up @@ -302,34 +258,6 @@ public final Builder transportAddress(String value) {
return this;
}

/**
* API name: {@code roles}
* <p>
* Adds all elements of <code>list</code> to <code>roles</code>.
*/
public final Builder roles(List<NodeRole> list) {
this.roles = _listAddAll(this.roles, list);
return this;
}

/**
* API name: {@code roles}
* <p>
* Adds one or more values to <code>roles</code>.
*/
public final Builder roles(NodeRole value, NodeRole... values) {
this.roles = _listAdd(this.roles, value, values);
return this;
}

/**
* API name: {@code external_id}
*/
public final Builder externalId(@Nullable String value) {
this.externalId = value;
return this;
}

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -364,8 +292,6 @@ protected static void setupNodeAttributesDeserializer(ObjectDeserializer<NodeAtt
op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id");
op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name");
op.add(Builder::transportAddress, JsonpDeserializer.stringDeserializer(), "transport_address");
op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(NodeRole._DESERIALIZER), "roles");
op.add(Builder::externalId, JsonpDeserializer.stringDeserializer(), "external_id");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public enum Kind implements JsonEnum {

TTest("t_test"),

TimeSeries("time_series"),

TopHits("top_hits"),

TopMetrics("top_metrics"),
Expand Down Expand Up @@ -1307,6 +1309,23 @@ public TTestAggregate tTest() {
return TaggedUnionUtils.get(this, Kind.TTest);
}

/**
* Is this variant instance of kind {@code time_series}?
*/
public boolean isTimeSeries() {
return _kind == Kind.TimeSeries;
}

/**
* Get the {@code time_series} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code time_series} kind.
*/
public TimeSeriesAggregate timeSeries() {
return TaggedUnionUtils.get(this, Kind.TimeSeries);
}

/**
* Is this variant instance of kind {@code top_hits}?
*/
Expand Down Expand Up @@ -2156,6 +2175,17 @@ public ObjectBuilder<Aggregate> tTest(Function<TTestAggregate.Builder, ObjectBui
return this.tTest(fn.apply(new TTestAggregate.Builder()).build());
}

public ObjectBuilder<Aggregate> timeSeries(TimeSeriesAggregate v) {
this._kind = Kind.TimeSeries;
this._value = v;
return this;
}

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

public ObjectBuilder<Aggregate> topHits(TopHitsAggregate v) {
this._kind = Kind.TopHits;
this._value = v;
Expand Down Expand Up @@ -2342,6 +2372,7 @@ public Aggregate build() {
deserializers.put("tdigest_percentile_ranks", TDigestPercentileRanksAggregate._DESERIALIZER);
deserializers.put("tdigest_percentiles", TDigestPercentilesAggregate._DESERIALIZER);
deserializers.put("t_test", TTestAggregate._DESERIALIZER);
deserializers.put("time_series", TimeSeriesAggregate._DESERIALIZER);
deserializers.put("top_hits", TopHitsAggregate._DESERIALIZER);
deserializers.put("top_metrics", TopMetricsAggregate._DESERIALIZER);
deserializers.put("umrareterms", UnmappedRareTermsAggregate._DESERIALIZER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,24 @@ public static Aggregate tTest(Function<TTestAggregate.Builder, ObjectBuilder<TTe
return builder.build();
}

/**
* Creates a builder for the {@link TimeSeriesAggregate time_series}
* {@code Aggregate} variant.
*/
public static TimeSeriesAggregate.Builder timeSeries() {
return new TimeSeriesAggregate.Builder();
}

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

/**
* Creates a builder for the {@link TopHitsAggregate top_hits} {@code Aggregate}
* variant.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ public enum Kind implements JsonEnum {

Terms("terms"),

TimeSeries("time_series"),

TopHits("top_hits"),

TTest("t_test"),
Expand Down Expand Up @@ -1493,6 +1495,23 @@ public TermsAggregation terms() {
return TaggedUnionUtils.get(this, Kind.Terms);
}

/**
* Is this variant instance of kind {@code time_series}?
*/
public boolean isTimeSeries() {
return _kind == Kind.TimeSeries;
}

/**
* Get the {@code time_series} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code time_series} kind.
*/
public TimeSeriesAggregation timeSeries() {
return TaggedUnionUtils.get(this, Kind.TimeSeries);
}

/**
* Is this variant instance of kind {@code top_hits}?
*/
Expand Down Expand Up @@ -2477,6 +2496,17 @@ public ContainerBuilder terms(Function<TermsAggregation.Builder, ObjectBuilder<T
return this.terms(fn.apply(new TermsAggregation.Builder()).build());
}

public ContainerBuilder timeSeries(TimeSeriesAggregation v) {
this._kind = Kind.TimeSeries;
this._value = v;
return new ContainerBuilder();
}

public ContainerBuilder timeSeries(
Function<TimeSeriesAggregation.Builder, ObjectBuilder<TimeSeriesAggregation>> fn) {
return this.timeSeries(fn.apply(new TimeSeriesAggregation.Builder()).build());
}

public ContainerBuilder topHits(TopHitsAggregation v) {
this._kind = Kind.TopHits;
this._value = v;
Expand Down Expand Up @@ -2702,6 +2732,7 @@ protected static void setupAggregationDeserializer(ObjectDeserializer<Builder> o
op.add(Builder::sum, SumAggregation._DESERIALIZER, "sum");
op.add(Builder::sumBucket, SumBucketAggregation._DESERIALIZER, "sum_bucket");
op.add(Builder::terms, TermsAggregation._DESERIALIZER, "terms");
op.add(Builder::timeSeries, TimeSeriesAggregation._DESERIALIZER, "time_series");
op.add(Builder::topHits, TopHitsAggregation._DESERIALIZER, "top_hits");
op.add(Builder::tTest, TTestAggregation._DESERIALIZER, "t_test");
op.add(Builder::topMetrics, TopMetricsAggregation._DESERIALIZER, "top_metrics");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,25 @@ public static Aggregation terms(Function<TermsAggregation.Builder, ObjectBuilder
return builder.build();
}

/**
* Creates a builder for the {@link TimeSeriesAggregation time_series}
* {@code Aggregation} variant.
*/
public static TimeSeriesAggregation.Builder timeSeries() {
return new TimeSeriesAggregation.Builder();
}

/**
* Creates a Aggregation of the {@link TimeSeriesAggregation time_series}
* {@code Aggregation} variant.
*/
public static Aggregation timeSeries(
Function<TimeSeriesAggregation.Builder, ObjectBuilder<TimeSeriesAggregation>> fn) {
Aggregation.Builder builder = new Aggregation.Builder();
builder.timeSeries(fn.apply(new TimeSeriesAggregation.Builder()).build());
return builder.build();
}

/**
* Creates a builder for the {@link TopHitsAggregation top_hits}
* {@code Aggregation} variant.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public static AggregationRange of(Function<Builder, ObjectBuilder<AggregationRan
* Start of the range (inclusive).
* <p>
* API name: {@code from}
* <p>
* Defaults to {@code 0} if parsed from a JSON {@code null} value.
*/
@Nullable
public final Double from() {
Expand All @@ -107,6 +109,8 @@ public final String key() {
* End of the range (exclusive).
* <p>
* API name: {@code to}
* <p>
* Defaults to {@code 0} if parsed from a JSON {@code null} value.
*/
@Nullable
public final Double to() {
Expand All @@ -126,8 +130,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

if (this.from != null) {
generator.writeKey("from");
generator.write(this.from);

JsonpUtils.serializeDoubleOrNull(generator, this.from, 0);
}
if (this.key != null) {
generator.writeKey("key");
Expand All @@ -136,8 +139,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}
if (this.to != null) {
generator.writeKey("to");
generator.write(this.to);

JsonpUtils.serializeDoubleOrNull(generator, this.to, 0);
}

}
Expand Down Expand Up @@ -167,6 +169,8 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder> implement
* Start of the range (inclusive).
* <p>
* API name: {@code from}
* <p>
* Defaults to {@code 0} if parsed from a JSON {@code null} value.
*/
public final Builder from(@Nullable Double value) {
this.from = value;
Expand All @@ -187,6 +191,8 @@ public final Builder key(@Nullable String value) {
* End of the range (exclusive).
* <p>
* API name: {@code to}
* <p>
* Defaults to {@code 0} if parsed from a JSON {@code null} value.
*/
public final Builder to(@Nullable Double value) {
this.to = value;
Expand Down Expand Up @@ -221,9 +227,9 @@ public AggregationRange build() {

protected static void setupAggregationRangeDeserializer(ObjectDeserializer<AggregationRange.Builder> op) {

op.add(Builder::from, JsonpDeserializer.doubleDeserializer(), "from");
op.add(Builder::from, JsonpDeserializer.doubleOrNullDeserializer(0), "from");
op.add(Builder::key, JsonpDeserializer.stringDeserializer(), "key");
op.add(Builder::to, JsonpDeserializer.doubleDeserializer(), "to");
op.add(Builder::to, JsonpDeserializer.doubleOrNullDeserializer(0), "to");

}

Expand Down
Loading

0 comments on commit be1f9aa

Please sign in to comment.