Skip to content

Commit 436c558

Browse files
opensearch-trigger-bot[bot]github-actions[bot]Xtansia
authored
[Backport 3.x] Re-generated client code using latest OpenSearch API specification (#1589)
* Re-generate client code using latest OpenSearch API specification (2025-06-02) (#1586) Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> (cherry picked from commit 3a72913) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * changelog Signed-off-by: Thomas Farr <tsfarr@amazon.com> --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Thomas Farr <tsfarr@amazon.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Thomas Farr <tsfarr@amazon.com>
1 parent d9b695f commit 436c558

6 files changed

Lines changed: 155 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
2020

2121
## [Unreleased 2.x]
2222
### Added
23+
- Added support for the `template` query type ([#1586](https://github.com/opensearch-project/opensearch-java/pull/1586))
24+
- Added support for Search Shards request `slice` property ([#1586](https://github.com/opensearch-project/opensearch-java/pull/1586))
2325

2426
### Dependencies
2527

java-client/src/generated/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@
3737
package org.opensearch.client.opensearch._types.query_dsl;
3838

3939
import jakarta.json.stream.JsonGenerator;
40+
import java.util.Map;
4041
import java.util.Objects;
4142
import java.util.function.Function;
4243
import javax.annotation.Generated;
4344
import javax.annotation.Nonnull;
45+
import org.opensearch.client.json.JsonData;
4446
import org.opensearch.client.json.JsonEnum;
4547
import org.opensearch.client.json.JsonpDeserializable;
4648
import org.opensearch.client.json.JsonpDeserializer;
@@ -61,7 +63,7 @@
6163

6264
@JsonpDeserializable
6365
@Generated("org.opensearch.client.codegen.CodeGenerator")
64-
public class Query implements TaggedUnion<Query.Kind, QueryVariant>, AggregationVariant, PlainJsonSerializable {
66+
public class Query implements TaggedUnion<Query.Kind, Object>, AggregationVariant, PlainJsonSerializable {
6567
/**
6668
* {@link Query} variant kinds.
6769
*/
@@ -116,6 +118,7 @@ public enum Kind implements JsonEnum {
116118
SpanOr("span_or"),
117119
SpanTerm("span_term"),
118120
SpanWithin("span_within"),
121+
Template("template"),
119122
Term("term"),
120123
Terms("terms"),
121124
TermsSet("terms_set"),
@@ -145,15 +148,15 @@ public Aggregation.Kind _aggregationKind() {
145148
}
146149

147150
private final Kind _kind;
148-
private final QueryVariant _value;
151+
private final Object _value;
149152

150153
@Override
151154
public final Kind _kind() {
152155
return _kind;
153156
}
154157

155158
@Override
156-
public final QueryVariant _get() {
159+
public final Object _get() {
157160
return _value;
158161
}
159162

@@ -971,6 +974,22 @@ public SpanWithinQuery spanWithin() {
971974
return TaggedUnionUtils.get(this, Kind.SpanWithin);
972975
}
973976

977+
/**
978+
* Is this variant instance of kind {@code template}?
979+
*/
980+
public boolean isTemplate() {
981+
return _kind == Kind.Template;
982+
}
983+
984+
/**
985+
* Get the {@code template} variant value.
986+
*
987+
* @throws IllegalStateException if the current variant is not the {@code template} kind.
988+
*/
989+
public Map<String, JsonData> template() {
990+
return TaggedUnionUtils.get(this, Kind.Template);
991+
}
992+
974993
/**
975994
* Is this variant instance of kind {@code term}?
976995
*/
@@ -1089,6 +1108,17 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
10891108
generator.writeKey(_kind.jsonValue());
10901109
if (_value instanceof JsonpSerializable) {
10911110
((JsonpSerializable) _value).serialize(generator, mapper);
1111+
} else {
1112+
switch (_kind) {
1113+
case Template:
1114+
generator.writeStartObject();
1115+
for (Map.Entry<String, JsonData> item0 : ((Map<String, JsonData>) this._value).entrySet()) {
1116+
generator.writeKey(item0.getKey());
1117+
item0.getValue().serialize(generator, mapper);
1118+
}
1119+
generator.writeEnd();
1120+
break;
1121+
}
10921122
}
10931123
generator.writeEnd();
10941124
}
@@ -1105,7 +1135,7 @@ public static Builder builder() {
11051135

11061136
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<Query> {
11071137
private Kind _kind;
1108-
private QueryVariant _value;
1138+
private Object _value;
11091139

11101140
public Builder() {}
11111141

@@ -1614,6 +1644,12 @@ public ObjectBuilder<Query> spanWithin(Function<SpanWithinQuery.Builder, ObjectB
16141644
return this.spanWithin(fn.apply(new SpanWithinQuery.Builder()).build());
16151645
}
16161646

1647+
public ObjectBuilder<Query> template(Map<String, JsonData> v) {
1648+
this._kind = Kind.Template;
1649+
this._value = v;
1650+
return this;
1651+
}
1652+
16171653
public ObjectBuilder<Query> term(TermQuery v) {
16181654
this._kind = Kind.Term;
16191655
this._value = v;
@@ -1742,6 +1778,7 @@ protected static void setupQueryDeserializer(ObjectDeserializer<Builder> op) {
17421778
op.add(Builder::spanOr, SpanOrQuery._DESERIALIZER, "span_or");
17431779
op.add(Builder::spanTerm, SpanTermQuery._DESERIALIZER, "span_term");
17441780
op.add(Builder::spanWithin, SpanWithinQuery._DESERIALIZER, "span_within");
1781+
op.add(Builder::template, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "template");
17451782
op.add(Builder::term, TermQuery._DESERIALIZER, "term");
17461783
op.add(Builder::terms, TermsQuery._DESERIALIZER, "terms");
17471784
op.add(Builder::termsSet, TermsSetQuery._DESERIALIZER, "terms_set");

java-client/src/generated/java/org/opensearch/client/opensearch/_types/query_dsl/QueryBuilders.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
import javax.annotation.Generated;
4040

4141
/**
42+
* <p>
4243
* Builders for {@link Query} variants.
44+
* </p>
45+
* <p>
46+
* Variants <code>template</code> are not available here as they don't have a dedicated class. Use {@link Query}'s builder for these.
47+
* </p>
4348
*/
4449
@Generated("org.opensearch.client.codegen.CodeGenerator")
4550
public class QueryBuilders {

java-client/src/generated/java/org/opensearch/client/opensearch/cluster/ExistsComponentTemplateRequest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public final Time clusterManagerTimeout() {
107107
}
108108

109109
/**
110-
* When <code>true</code>, the request retrieves information from the local node only. When `false, information is retrieved from the
111-
* cluster manager node.
110+
* When <code>true</code>, the request retrieves information from the local node only. When <code>false</code>, information is retrieved
111+
* from the cluster manager node.
112112
* <p>
113113
* API name: {@code local}
114114
* </p>
@@ -226,8 +226,8 @@ public final Builder clusterManagerTimeout(Function<Time.Builder, ObjectBuilder<
226226
}
227227

228228
/**
229-
* When <code>true</code>, the request retrieves information from the local node only. When `false, information is retrieved from
230-
* the cluster manager node.
229+
* When <code>true</code>, the request retrieves information from the local node only. When <code>false</code>, information is
230+
* retrieved from the cluster manager node.
231231
* <p>
232232
* API name: {@code local}
233233
* </p>

java-client/src/generated/java/org/opensearch/client/opensearch/core/SearchShardsRequest.java

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
package org.opensearch.client.opensearch.core;
3838

39+
import jakarta.json.stream.JsonGenerator;
3940
import java.util.HashMap;
4041
import java.util.List;
4142
import java.util.Map;
@@ -45,9 +46,16 @@
4546
import javax.annotation.Generated;
4647
import javax.annotation.Nonnull;
4748
import javax.annotation.Nullable;
49+
import org.opensearch.client.json.JsonpDeserializable;
50+
import org.opensearch.client.json.JsonpDeserializer;
51+
import org.opensearch.client.json.JsonpMapper;
52+
import org.opensearch.client.json.ObjectBuilderDeserializer;
53+
import org.opensearch.client.json.ObjectDeserializer;
54+
import org.opensearch.client.json.PlainJsonSerializable;
4855
import org.opensearch.client.opensearch._types.ErrorResponse;
4956
import org.opensearch.client.opensearch._types.ExpandWildcard;
5057
import org.opensearch.client.opensearch._types.RequestBase;
58+
import org.opensearch.client.opensearch._types.SlicedScroll;
5159
import org.opensearch.client.transport.Endpoint;
5260
import org.opensearch.client.transport.endpoints.SimpleEndpoint;
5361
import org.opensearch.client.util.ApiTypeHelper;
@@ -60,8 +68,12 @@
6068
/**
6169
* Returns information about the indexes and shards that a search request would be executed against.
6270
*/
71+
@JsonpDeserializable
6372
@Generated("org.opensearch.client.codegen.CodeGenerator")
64-
public final class SearchShardsRequest extends RequestBase implements ToCopyableBuilder<SearchShardsRequest.Builder, SearchShardsRequest> {
73+
public final class SearchShardsRequest extends RequestBase
74+
implements
75+
PlainJsonSerializable,
76+
ToCopyableBuilder<SearchShardsRequest.Builder, SearchShardsRequest> {
6577

6678
@Nullable
6779
private final Boolean allowNoIndices;
@@ -84,6 +96,9 @@ public final class SearchShardsRequest extends RequestBase implements ToCopyable
8496
@Nonnull
8597
private final List<String> routing;
8698

99+
@Nullable
100+
private final SlicedScroll slice;
101+
87102
// ---------------------------------------------------------------------------------------------
88103

89104
private SearchShardsRequest(Builder builder) {
@@ -95,6 +110,7 @@ private SearchShardsRequest(Builder builder) {
95110
this.local = builder.local;
96111
this.preference = builder.preference;
97112
this.routing = ApiTypeHelper.unmodifiable(builder.routing);
113+
this.slice = builder.slice;
98114
}
99115

100116
public static SearchShardsRequest of(Function<SearchShardsRequest.Builder, ObjectBuilder<SearchShardsRequest>> fn) {
@@ -182,6 +198,31 @@ public final List<String> routing() {
182198
return this.routing;
183199
}
184200

201+
/**
202+
* API name: {@code slice}
203+
*/
204+
@Nullable
205+
public final SlicedScroll slice() {
206+
return this.slice;
207+
}
208+
209+
/**
210+
* Serialize this object to JSON.
211+
*/
212+
@Override
213+
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
214+
generator.writeStartObject();
215+
serializeInternal(generator, mapper);
216+
generator.writeEnd();
217+
}
218+
219+
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
220+
if (this.slice != null) {
221+
generator.writeKey("slice");
222+
this.slice.serialize(generator, mapper);
223+
}
224+
}
225+
185226
// ---------------------------------------------------------------------------------------------
186227

187228
@Override
@@ -213,6 +254,8 @@ public static class Builder extends RequestBase.AbstractBuilder<Builder> impleme
213254
private String preference;
214255
@Nullable
215256
private List<String> routing;
257+
@Nullable
258+
private SlicedScroll slice;
216259

217260
public Builder() {}
218261

@@ -225,6 +268,7 @@ private Builder(SearchShardsRequest o) {
225268
this.local = o.local;
226269
this.preference = o.preference;
227270
this.routing = _listCopy(o.routing);
271+
this.slice = o.slice;
228272
}
229273

230274
private Builder(Builder o) {
@@ -236,6 +280,7 @@ private Builder(Builder o) {
236280
this.local = o.local;
237281
this.preference = o.preference;
238282
this.routing = _listCopy(o.routing);
283+
this.slice = o.slice;
239284
}
240285

241286
@Override
@@ -401,6 +446,23 @@ public final Builder routing(String value, String... values) {
401446
return this;
402447
}
403448

449+
/**
450+
* API name: {@code slice}
451+
*/
452+
@Nonnull
453+
public final Builder slice(@Nullable SlicedScroll value) {
454+
this.slice = value;
455+
return this;
456+
}
457+
458+
/**
459+
* API name: {@code slice}
460+
*/
461+
@Nonnull
462+
public final Builder slice(Function<SlicedScroll.Builder, ObjectBuilder<SlicedScroll>> fn) {
463+
return slice(fn.apply(new SlicedScroll.Builder()).build());
464+
}
465+
404466
/**
405467
* Builds a {@link SearchShardsRequest}.
406468
*
@@ -417,6 +479,20 @@ public SearchShardsRequest build() {
417479

418480
// ---------------------------------------------------------------------------------------------
419481

482+
/**
483+
* Json deserializer for {@link SearchShardsRequest}
484+
*/
485+
public static final JsonpDeserializer<SearchShardsRequest> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
486+
Builder::new,
487+
SearchShardsRequest::setupSearchShardsRequestDeserializer
488+
);
489+
490+
protected static void setupSearchShardsRequestDeserializer(ObjectDeserializer<SearchShardsRequest.Builder> op) {
491+
op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice");
492+
}
493+
494+
// ---------------------------------------------------------------------------------------------
495+
420496
@Override
421497
protected void applyQueryParameters(@Nonnull Map<String, String> params) {
422498
super.applyQueryParameters(params);
@@ -474,7 +550,7 @@ protected void applyQueryParameters(@Nonnull Map<String, String> params) {
474550
return params;
475551
},
476552
SimpleEndpoint.emptyMap(),
477-
false,
553+
true,
478554
SearchShardsResponse._DESERIALIZER
479555
);
480556

@@ -488,6 +564,7 @@ public int hashCode() {
488564
result = 31 * result + Objects.hashCode(this.local);
489565
result = 31 * result + Objects.hashCode(this.preference);
490566
result = 31 * result + Objects.hashCode(this.routing);
567+
result = 31 * result + Objects.hashCode(this.slice);
491568
return result;
492569
}
493570

@@ -502,6 +579,7 @@ public boolean equals(Object o) {
502579
&& Objects.equals(this.index, other.index)
503580
&& Objects.equals(this.local, other.local)
504581
&& Objects.equals(this.preference, other.preference)
505-
&& Objects.equals(this.routing, other.routing);
582+
&& Objects.equals(this.routing, other.routing)
583+
&& Objects.equals(this.slice, other.slice);
506584
}
507585
}

0 commit comments

Comments
 (0)