Skip to content

Commit 786e58d

Browse files
authored
Generate aggregation types (#1392)
* Generating Signed-off-by: Thomas Farr <[email protected]> * Re-generate Signed-off-by: Thomas Farr <[email protected]> * Generating 2 Signed-off-by: Thomas Farr <[email protected]> * Generating 3 Signed-off-by: Thomas Farr <[email protected]> * Generating 4 Signed-off-by: Thomas Farr <[email protected]> * Fix build Signed-off-by: Thomas Farr <[email protected]> --------- Signed-off-by: Thomas Farr <[email protected]>
1 parent cc8d3f7 commit 786e58d

File tree

174 files changed

+16868
-5148
lines changed

Some content is hidden

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

174 files changed

+16868
-5148
lines changed

UPGRADING.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -561,4 +561,22 @@ After:
561561
- The `file` property has been removed as it is not supported by OpenSearch.
562562

563563
### SearchShardsRequest
564-
- The `routing` property is now of type `List<String>` instead of `String`.
564+
- The `routing` property is now of type `List<String>` instead of `String`.
565+
566+
### CompositeAggregation
567+
- The `after` property is now of type `Map<String, FieldValue>` instead of `Map<String, String>`.
568+
569+
### CompositeDateHistogramAggregationSource
570+
- The `offset` property has been corrected to be of type `Time` instead of `Long`.
571+
572+
### CompositeValuesSource
573+
- The `format` property has been removed as it only applies to certain subclasses.
574+
575+
### InferenceConfig
576+
- The `InferenceConfig` class has been changed to a tagged union.
577+
578+
### SignificantTermsAggregation
579+
- The `include` property is now of type `TermsInclude` instead of `List<String>`.
580+
581+
### SignificantTextAggregation
582+
- The `include` property is now of type `TermsInclude` instead of `List<String>`.

java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashPrecision.java java-client/src/generated/java/org/opensearch/client/opensearch/_types/GeoHashPrecision.java

+85-51
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,22 @@
3030
* GitHub history for details.
3131
*/
3232

33+
//----------------------------------------------------
34+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
35+
//----------------------------------------------------
36+
3337
package org.opensearch.client.opensearch._types;
3438

3539
import jakarta.json.stream.JsonGenerator;
40+
import java.util.Objects;
3641
import java.util.function.Function;
42+
import javax.annotation.Generated;
43+
import javax.annotation.Nonnull;
3744
import org.opensearch.client.json.JsonpDeserializable;
3845
import org.opensearch.client.json.JsonpDeserializer;
3946
import org.opensearch.client.json.JsonpMapper;
4047
import org.opensearch.client.json.JsonpSerializable;
48+
import org.opensearch.client.json.PlainJsonSerializable;
4149
import org.opensearch.client.json.UnionDeserializer;
4250
import org.opensearch.client.util.ApiTypeHelper;
4351
import org.opensearch.client.util.ObjectBuilder;
@@ -48,17 +56,18 @@
4856
// typedef: _types.GeoHashPrecision
4957

5058
/**
51-
* A precision that can be expressed as a geohash length between 1 and 12, or a
52-
* distance measure like &quot;1km&quot;, &quot;10m&quot;.
53-
*
59+
* The level of geohash precision, which can be expressed as a geohash length between 1 and 12 or as a distance measure, such as
60+
* &quot;1km&quot; or &quot;10m&quot;.
5461
*/
5562
@JsonpDeserializable
56-
public class GeoHashPrecision implements TaggedUnion<GeoHashPrecision.Kind, Object>, JsonpSerializable {
57-
63+
@Generated("org.opensearch.client.codegen.CodeGenerator")
64+
public class GeoHashPrecision implements TaggedUnion<GeoHashPrecision.Kind, Object>, PlainJsonSerializable {
65+
/**
66+
* {@link GeoHashPrecision} variant kinds.
67+
*/
5868
public enum Kind {
59-
GeohashLength,
60-
Distance
61-
69+
Distance,
70+
GeohashLength
6271
}
6372

6473
private final Kind _kind;
@@ -79,61 +88,56 @@ private GeoHashPrecision(Kind kind, Object value) {
7988
this._value = value;
8089
}
8190

91+
private GeoHashPrecision(Builder builder) {
92+
this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
93+
this._value = ApiTypeHelper.requireNonNull(builder._value, builder, "<variant value>");
94+
}
95+
96+
public static GeoHashPrecision of(Function<GeoHashPrecision.Builder, ObjectBuilder<GeoHashPrecision>> fn) {
97+
return fn.apply(new Builder()).build();
98+
}
99+
82100
public String _toJsonString() {
83101
switch (_kind) {
84-
case GeohashLength:
85-
return this.geohashLength().toString();
86102
case Distance:
87103
return this.distance();
88-
104+
case GeohashLength:
105+
return String.valueOf(this.geohashLength());
89106
default:
90107
throw new IllegalStateException("Unknown kind " + _kind);
91108
}
92109
}
93110

94-
private GeoHashPrecision(Builder builder) {
95-
96-
this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
97-
this._value = ApiTypeHelper.requireNonNull(builder._value, builder, "<variant value>");
98-
99-
}
100-
101-
public static GeoHashPrecision of(Function<Builder, ObjectBuilder<GeoHashPrecision>> fn) {
102-
return fn.apply(new Builder()).build();
103-
}
104-
105111
/**
106-
* Is this variant instance of kind {@code geohash_length}?
112+
* Is this variant instance of kind {@code distance}?
107113
*/
108-
public boolean isGeohashLength() {
109-
return _kind == Kind.GeohashLength;
114+
public boolean isDistance() {
115+
return _kind == Kind.Distance;
110116
}
111117

112118
/**
113-
* Get the {@code geohash_length} variant value.
119+
* Get the {@code distance} variant value.
114120
*
115-
* @throws IllegalStateException
116-
* if the current variant is not of the {@code geohash_length} kind.
121+
* @throws IllegalStateException if the current variant is not the {@code distance} kind.
117122
*/
118-
public Number geohashLength() {
119-
return TaggedUnionUtils.get(this, Kind.GeohashLength);
123+
public String distance() {
124+
return TaggedUnionUtils.get(this, Kind.Distance);
120125
}
121126

122127
/**
123-
* Is this variant instance of kind {@code distance}?
128+
* Is this variant instance of kind {@code geohash_length}?
124129
*/
125-
public boolean isDistance() {
126-
return _kind == Kind.Distance;
130+
public boolean isGeohashLength() {
131+
return _kind == Kind.GeohashLength;
127132
}
128133

129134
/**
130-
* Get the {@code distance} variant value.
135+
* Get the {@code geohash_length} variant value.
131136
*
132-
* @throws IllegalStateException
133-
* if the current variant is not of the {@code distance} kind.
137+
* @throws IllegalStateException if the current variant is not the {@code geohash_length} kind.
134138
*/
135-
public String distance() {
136-
return TaggedUnionUtils.get(this, Kind.Distance);
139+
public Integer geohashLength() {
140+
return TaggedUnionUtils.get(this, Kind.GeohashLength);
137141
}
138142

139143
@Override
@@ -142,27 +146,35 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
142146
((JsonpSerializable) _value).serialize(generator, mapper);
143147
} else {
144148
switch (_kind) {
145-
case GeohashLength:
146-
generator.write(((Number) this._value).doubleValue());
147-
148-
break;
149149
case Distance:
150150
generator.write(((String) this._value));
151-
151+
break;
152+
case GeohashLength:
153+
generator.write(((Integer) this._value));
152154
break;
153155
}
154156
}
157+
}
155158

159+
@Nonnull
160+
public Builder toBuilder() {
161+
return new Builder(this);
162+
}
163+
164+
@Nonnull
165+
public static Builder builder() {
166+
return new Builder();
156167
}
157168

158169
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<GeoHashPrecision> {
159170
private Kind _kind;
160171
private Object _value;
161172

162-
public ObjectBuilder<GeoHashPrecision> geohashLength(Number v) {
163-
this._kind = Kind.GeohashLength;
164-
this._value = v;
165-
return this;
173+
public Builder() {}
174+
175+
private Builder(GeoHashPrecision o) {
176+
this._kind = o._kind;
177+
this._value = o._value;
166178
}
167179

168180
public ObjectBuilder<GeoHashPrecision> distance(String v) {
@@ -171,21 +183,43 @@ public ObjectBuilder<GeoHashPrecision> distance(String v) {
171183
return this;
172184
}
173185

186+
public ObjectBuilder<GeoHashPrecision> geohashLength(Integer v) {
187+
this._kind = Kind.GeohashLength;
188+
this._value = v;
189+
return this;
190+
}
191+
192+
@Override
174193
public GeoHashPrecision build() {
175194
_checkSingleUse();
176195
return new GeoHashPrecision(this);
177196
}
178-
179197
}
180198

181199
private static JsonpDeserializer<GeoHashPrecision> buildGeoHashPrecisionDeserializer() {
182200
return new UnionDeserializer.Builder<GeoHashPrecision, Kind, Object>(GeoHashPrecision::new, false).addMember(
183-
Kind.GeohashLength,
184-
JsonpDeserializer.numberDeserializer()
185-
).addMember(Kind.Distance, JsonpDeserializer.stringDeserializer()).build();
201+
Kind.Distance,
202+
JsonpDeserializer.stringDeserializer()
203+
).addMember(Kind.GeohashLength, JsonpDeserializer.integerDeserializer()).build();
186204
}
187205

188206
public static final JsonpDeserializer<GeoHashPrecision> _DESERIALIZER = JsonpDeserializer.lazy(
189207
GeoHashPrecision::buildGeoHashPrecisionDeserializer
190208
);
209+
210+
@Override
211+
public int hashCode() {
212+
int result = 17;
213+
result = 31 * result + Objects.hashCode(this._kind);
214+
result = 31 * result + Objects.hashCode(this._value);
215+
return result;
216+
}
217+
218+
@Override
219+
public boolean equals(Object o) {
220+
if (this == o) return true;
221+
if (o == null || this.getClass() != o.getClass()) return false;
222+
GeoHashPrecision other = (GeoHashPrecision) o;
223+
return Objects.equals(this._kind, other._kind) && Objects.equals(this._value, other._value);
224+
}
191225
}

0 commit comments

Comments
 (0)