Skip to content

Commit 949bdd3

Browse files
committed
[codegen] update to latest spec
1 parent 7c46ddd commit 949bdd3

File tree

50 files changed

+5480
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5480
-297
lines changed

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

+31
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ public enum Kind implements JsonEnum {
193193

194194
ReverseNested("reverse_nested"),
195195

196+
RandomSampler("random_sampler"),
197+
196198
Sampler("sampler"),
197199

198200
ScriptedMetric("scripted_metric"),
@@ -1305,6 +1307,23 @@ public ReverseNestedAggregation reverseNested() {
13051307
return TaggedUnionUtils.get(this, Kind.ReverseNested);
13061308
}
13071309

1310+
/**
1311+
* Is this variant instance of kind {@code random_sampler}?
1312+
*/
1313+
public boolean isRandomSampler() {
1314+
return _kind == Kind.RandomSampler;
1315+
}
1316+
1317+
/**
1318+
* Get the {@code random_sampler} variant value.
1319+
*
1320+
* @throws IllegalStateException
1321+
* if the current variant is not of the {@code random_sampler} kind.
1322+
*/
1323+
public RandomSamplerAggregation randomSampler() {
1324+
return TaggedUnionUtils.get(this, Kind.RandomSampler);
1325+
}
1326+
13081327
/**
13091328
* Is this variant instance of kind {@code sampler}?
13101329
*/
@@ -2379,6 +2398,17 @@ public ContainerBuilder reverseNested(
23792398
return this.reverseNested(fn.apply(new ReverseNestedAggregation.Builder()).build());
23802399
}
23812400

2401+
public ContainerBuilder randomSampler(RandomSamplerAggregation v) {
2402+
this._kind = Kind.RandomSampler;
2403+
this._value = v;
2404+
return new ContainerBuilder();
2405+
}
2406+
2407+
public ContainerBuilder randomSampler(
2408+
Function<RandomSamplerAggregation.Builder, ObjectBuilder<RandomSamplerAggregation>> fn) {
2409+
return this.randomSampler(fn.apply(new RandomSamplerAggregation.Builder()).build());
2410+
}
2411+
23822412
public ContainerBuilder sampler(SamplerAggregation v) {
23832413
this._kind = Kind.Sampler;
23842414
this._value = v;
@@ -2721,6 +2751,7 @@ protected static void setupAggregationDeserializer(ObjectDeserializer<Builder> o
27212751
op.add(Builder::rareTerms, RareTermsAggregation._DESERIALIZER, "rare_terms");
27222752
op.add(Builder::rate, RateAggregation._DESERIALIZER, "rate");
27232753
op.add(Builder::reverseNested, ReverseNestedAggregation._DESERIALIZER, "reverse_nested");
2754+
op.add(Builder::randomSampler, RandomSamplerAggregation._DESERIALIZER, "random_sampler");
27242755
op.add(Builder::sampler, SamplerAggregation._DESERIALIZER, "sampler");
27252756
op.add(Builder::scriptedMetric, ScriptedMetricAggregation._DESERIALIZER, "scripted_metric");
27262757
op.add(Builder::serialDiff, SerialDifferencingAggregation._DESERIALIZER, "serial_diff");

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

+19
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,25 @@ public static Aggregation reverseNested(
11301130
return builder.build();
11311131
}
11321132

1133+
/**
1134+
* Creates a builder for the {@link RandomSamplerAggregation random_sampler}
1135+
* {@code Aggregation} variant.
1136+
*/
1137+
public static RandomSamplerAggregation.Builder randomSampler() {
1138+
return new RandomSamplerAggregation.Builder();
1139+
}
1140+
1141+
/**
1142+
* Creates a Aggregation of the {@link RandomSamplerAggregation random_sampler}
1143+
* {@code Aggregation} variant.
1144+
*/
1145+
public static Aggregation randomSampler(
1146+
Function<RandomSamplerAggregation.Builder, ObjectBuilder<RandomSamplerAggregation>> fn) {
1147+
Aggregation.Builder builder = new Aggregation.Builder();
1148+
builder.randomSampler(fn.apply(new RandomSamplerAggregation.Builder()).build());
1149+
return builder.build();
1150+
}
1151+
11331152
/**
11341153
* Creates a builder for the {@link SamplerAggregation sampler}
11351154
* {@code Aggregation} variant.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
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.aggregations;
21+
22+
import co.elastic.clients.json.JsonpDeserializable;
23+
import co.elastic.clients.json.JsonpDeserializer;
24+
import co.elastic.clients.json.JsonpMapper;
25+
import co.elastic.clients.json.JsonpSerializable;
26+
import co.elastic.clients.json.JsonpUtils;
27+
import co.elastic.clients.json.ObjectBuilderDeserializer;
28+
import co.elastic.clients.json.ObjectDeserializer;
29+
import co.elastic.clients.util.ApiTypeHelper;
30+
import co.elastic.clients.util.ObjectBuilder;
31+
import jakarta.json.stream.JsonGenerator;
32+
import java.lang.Double;
33+
import java.lang.Integer;
34+
import java.util.Objects;
35+
import java.util.function.Function;
36+
import javax.annotation.Nullable;
37+
38+
//----------------------------------------------------------------
39+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
40+
//----------------------------------------------------------------
41+
//
42+
// This code is generated from the Elasticsearch API specification
43+
// at https://github.com/elastic/elasticsearch-specification
44+
//
45+
// Manual updates to this file will be lost when the code is
46+
// re-generated.
47+
//
48+
// If you find a property that is missing or wrongly typed, please
49+
// open an issue or a PR on the API specification repository.
50+
//
51+
//----------------------------------------------------------------
52+
53+
// typedef: _types.aggregations.RandomSamplerAggregation
54+
55+
/**
56+
*
57+
* @see <a href=
58+
* "../../doc-files/api-spec.html#_types.aggregations.RandomSamplerAggregation">API
59+
* specification</a>
60+
*/
61+
@JsonpDeserializable
62+
public class RandomSamplerAggregation extends BucketAggregationBase implements AggregationVariant, JsonpSerializable {
63+
private final double probability;
64+
65+
@Nullable
66+
private final Integer seed;
67+
68+
@Nullable
69+
private final Integer shardSeed;
70+
71+
// ---------------------------------------------------------------------------------------------
72+
73+
private RandomSamplerAggregation(Builder builder) {
74+
75+
this.probability = ApiTypeHelper.requireNonNull(builder.probability, this, "probability");
76+
this.seed = builder.seed;
77+
this.shardSeed = builder.shardSeed;
78+
79+
}
80+
81+
public static RandomSamplerAggregation of(Function<Builder, ObjectBuilder<RandomSamplerAggregation>> fn) {
82+
return fn.apply(new Builder()).build();
83+
}
84+
85+
/**
86+
* Aggregation variant kind.
87+
*/
88+
@Override
89+
public Aggregation.Kind _aggregationKind() {
90+
return Aggregation.Kind.RandomSampler;
91+
}
92+
93+
/**
94+
* Required - The probability that a document will be included in the aggregated
95+
* data. Must be greater than 0, less than 0.5, or exactly 1. The lower the
96+
* probability, the fewer documents are matched.
97+
* <p>
98+
* API name: {@code probability}
99+
*/
100+
public final double probability() {
101+
return this.probability;
102+
}
103+
104+
/**
105+
* The seed to generate the random sampling of documents. When a seed is
106+
* provided, the random subset of documents is the same between calls.
107+
* <p>
108+
* API name: {@code seed}
109+
*/
110+
@Nullable
111+
public final Integer seed() {
112+
return this.seed;
113+
}
114+
115+
/**
116+
* When combined with seed, setting shard_seed ensures 100% consistent sampling
117+
* over shards where data is exactly the same.
118+
* <p>
119+
* API name: {@code shard_seed}
120+
*/
121+
@Nullable
122+
public final Integer shardSeed() {
123+
return this.shardSeed;
124+
}
125+
126+
/**
127+
* Serialize this object to JSON.
128+
*/
129+
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
130+
generator.writeStartObject();
131+
serializeInternal(generator, mapper);
132+
generator.writeEnd();
133+
}
134+
135+
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
136+
137+
generator.writeKey("probability");
138+
generator.write(this.probability);
139+
140+
if (this.seed != null) {
141+
generator.writeKey("seed");
142+
generator.write(this.seed);
143+
144+
}
145+
if (this.shardSeed != null) {
146+
generator.writeKey("shard_seed");
147+
generator.write(this.shardSeed);
148+
149+
}
150+
151+
}
152+
153+
@Override
154+
public String toString() {
155+
return JsonpUtils.toString(this);
156+
}
157+
158+
// ---------------------------------------------------------------------------------------------
159+
160+
/**
161+
* Builder for {@link RandomSamplerAggregation}.
162+
*/
163+
164+
public static class Builder extends BucketAggregationBase.AbstractBuilder<Builder>
165+
implements
166+
ObjectBuilder<RandomSamplerAggregation> {
167+
private Double probability;
168+
169+
@Nullable
170+
private Integer seed;
171+
172+
@Nullable
173+
private Integer shardSeed;
174+
175+
/**
176+
* Required - The probability that a document will be included in the aggregated
177+
* data. Must be greater than 0, less than 0.5, or exactly 1. The lower the
178+
* probability, the fewer documents are matched.
179+
* <p>
180+
* API name: {@code probability}
181+
*/
182+
public final Builder probability(double value) {
183+
this.probability = value;
184+
return this;
185+
}
186+
187+
/**
188+
* The seed to generate the random sampling of documents. When a seed is
189+
* provided, the random subset of documents is the same between calls.
190+
* <p>
191+
* API name: {@code seed}
192+
*/
193+
public final Builder seed(@Nullable Integer value) {
194+
this.seed = value;
195+
return this;
196+
}
197+
198+
/**
199+
* When combined with seed, setting shard_seed ensures 100% consistent sampling
200+
* over shards where data is exactly the same.
201+
* <p>
202+
* API name: {@code shard_seed}
203+
*/
204+
public final Builder shardSeed(@Nullable Integer value) {
205+
this.shardSeed = value;
206+
return this;
207+
}
208+
209+
@Override
210+
protected Builder self() {
211+
return this;
212+
}
213+
214+
/**
215+
* Builds a {@link RandomSamplerAggregation}.
216+
*
217+
* @throws NullPointerException
218+
* if some of the required fields are null.
219+
*/
220+
public RandomSamplerAggregation build() {
221+
_checkSingleUse();
222+
223+
return new RandomSamplerAggregation(this);
224+
}
225+
}
226+
227+
// ---------------------------------------------------------------------------------------------
228+
229+
/**
230+
* Json deserializer for {@link RandomSamplerAggregation}
231+
*/
232+
public static final JsonpDeserializer<RandomSamplerAggregation> _DESERIALIZER = ObjectBuilderDeserializer
233+
.lazy(Builder::new, RandomSamplerAggregation::setupRandomSamplerAggregationDeserializer);
234+
235+
protected static void setupRandomSamplerAggregationDeserializer(
236+
ObjectDeserializer<RandomSamplerAggregation.Builder> op) {
237+
238+
op.add(Builder::probability, JsonpDeserializer.doubleDeserializer(), "probability");
239+
op.add(Builder::seed, JsonpDeserializer.integerDeserializer(), "seed");
240+
op.add(Builder::shardSeed, JsonpDeserializer.integerDeserializer(), "shard_seed");
241+
242+
}
243+
244+
}

0 commit comments

Comments
 (0)