Skip to content

Commit 24faa6a

Browse files
committed
[codegen] Update to latest API specification
Fixes #132, fixes #123, fixes #89
1 parent 8efe513 commit 24faa6a

15 files changed

+1536
-145
lines changed

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

+66-4
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@
2525

2626
import co.elastic.clients.json.JsonpDeserializable;
2727
import co.elastic.clients.json.JsonpDeserializer;
28+
import co.elastic.clients.json.JsonpMapper;
2829
import co.elastic.clients.json.ObjectBuilderDeserializer;
2930
import co.elastic.clients.json.ObjectDeserializer;
31+
import co.elastic.clients.util.ApiTypeHelper;
3032
import co.elastic.clients.util.ObjectBuilder;
3133
import jakarta.json.stream.JsonGenerator;
34+
import java.util.List;
3235
import java.util.Objects;
3336
import java.util.function.Function;
37+
import javax.annotation.Nullable;
3438

3539
// typedef: _types.aggregations.TopMetricsAggregate
3640

@@ -41,12 +45,16 @@
4145
* specification</a>
4246
*/
4347
@JsonpDeserializable
44-
public class TopMetricsAggregate extends MultiBucketAggregateBase<TopMetricsBucket> implements AggregateVariant {
48+
public class TopMetricsAggregate extends AggregateBase implements AggregateVariant {
49+
private final List<TopMetrics> top;
50+
4551
// ---------------------------------------------------------------------------------------------
4652

4753
private TopMetricsAggregate(Builder builder) {
4854
super(builder);
4955

56+
this.top = ApiTypeHelper.unmodifiableRequired(builder.top, this, "top");
57+
5058
}
5159

5260
public static TopMetricsAggregate of(Function<Builder, ObjectBuilder<TopMetricsAggregate>> fn) {
@@ -61,15 +69,69 @@ public Aggregate.Kind _aggregateKind() {
6169
return Aggregate.Kind.TopMetrics;
6270
}
6371

72+
/**
73+
* Required - API name: {@code top}
74+
*/
75+
public final List<TopMetrics> top() {
76+
return this.top;
77+
}
78+
79+
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
80+
81+
super.serializeInternal(generator, mapper);
82+
if (ApiTypeHelper.isDefined(this.top)) {
83+
generator.writeKey("top");
84+
generator.writeStartArray();
85+
for (TopMetrics item0 : this.top) {
86+
item0.serialize(generator, mapper);
87+
88+
}
89+
generator.writeEnd();
90+
91+
}
92+
93+
}
94+
6495
// ---------------------------------------------------------------------------------------------
6596

6697
/**
6798
* Builder for {@link TopMetricsAggregate}.
6899
*/
69100

70-
public static class Builder extends MultiBucketAggregateBase.AbstractBuilder<TopMetricsBucket, Builder>
101+
public static class Builder extends AggregateBase.AbstractBuilder<Builder>
71102
implements
72103
ObjectBuilder<TopMetricsAggregate> {
104+
private List<TopMetrics> top;
105+
106+
/**
107+
* Required - API name: {@code top}
108+
* <p>
109+
* Adds all elements of <code>list</code> to <code>top</code>.
110+
*/
111+
public final Builder top(List<TopMetrics> list) {
112+
this.top = _listAddAll(this.top, list);
113+
return this;
114+
}
115+
116+
/**
117+
* Required - API name: {@code top}
118+
* <p>
119+
* Adds one or more values to <code>top</code>.
120+
*/
121+
public final Builder top(TopMetrics value, TopMetrics... values) {
122+
this.top = _listAdd(this.top, value, values);
123+
return this;
124+
}
125+
126+
/**
127+
* Required - API name: {@code top}
128+
* <p>
129+
* Adds a value to <code>top</code> using a builder lambda.
130+
*/
131+
public final Builder top(Function<TopMetrics.Builder, ObjectBuilder<TopMetrics>> fn) {
132+
return top(fn.apply(new TopMetrics.Builder()).build());
133+
}
134+
73135
@Override
74136
protected Builder self() {
75137
return this;
@@ -83,7 +145,6 @@ protected Builder self() {
83145
*/
84146
public TopMetricsAggregate build() {
85147
_checkSingleUse();
86-
super.tBucketSerializer(null);
87148

88149
return new TopMetricsAggregate(this);
89150
}
@@ -98,7 +159,8 @@ public TopMetricsAggregate build() {
98159
.lazy(Builder::new, TopMetricsAggregate::setupTopMetricsAggregateDeserializer);
99160

100161
protected static void setupTopMetricsAggregateDeserializer(ObjectDeserializer<TopMetricsAggregate.Builder> op) {
101-
MultiBucketAggregateBase.setupMultiBucketAggregateBaseDeserializer(op, TopMetricsBucket._DESERIALIZER);
162+
AggregateBase.setupAggregateBaseDeserializer(op);
163+
op.add(Builder::top, JsonpDeserializer.arrayDeserializer(TopMetrics._DESERIALIZER), "top");
102164

103165
}
104166

0 commit comments

Comments
 (0)