Skip to content

Commit 779e31a

Browse files
authored
Update Specification and Re-generate Code (#1890)
Signed-off-by: Andriy Redko <drreta@gmail.com>
1 parent 324769d commit 779e31a

37 files changed

Lines changed: 6408 additions & 1504 deletions
Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Licensed to Elasticsearch B.V. under one or more contributor
11+
* license agreements. See the NOTICE file distributed with
12+
* this work for additional information regarding copyright
13+
* ownership. Elasticsearch B.V. licenses this file to you under
14+
* the Apache License, Version 2.0 (the "License"); you may
15+
* not use this file except in compliance with the License.
16+
* You may obtain a copy of the License at
17+
*
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
*
20+
* Unless required by applicable law or agreed to in writing,
21+
* software distributed under the License is distributed on an
22+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23+
* KIND, either express or implied. See the License for the
24+
* specific language governing permissions and limitations
25+
* under the License.
26+
*/
27+
28+
/*
29+
* Modifications Copyright OpenSearch Contributors. See
30+
* GitHub history for details.
31+
*/
32+
33+
//----------------------------------------------------
34+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
35+
//----------------------------------------------------
36+
37+
package org.opensearch.client.opensearch._types;
38+
39+
import jakarta.json.stream.JsonGenerator;
40+
import java.util.Objects;
41+
import java.util.function.Function;
42+
import javax.annotation.Generated;
43+
import javax.annotation.Nonnull;
44+
import javax.annotation.Nullable;
45+
import org.opensearch.client.json.JsonpDeserializable;
46+
import org.opensearch.client.json.JsonpDeserializer;
47+
import org.opensearch.client.json.JsonpMapper;
48+
import org.opensearch.client.json.ObjectBuilderDeserializer;
49+
import org.opensearch.client.json.ObjectDeserializer;
50+
import org.opensearch.client.json.PlainJsonSerializable;
51+
import org.opensearch.client.util.ApiTypeHelper;
52+
import org.opensearch.client.util.CopyableBuilder;
53+
import org.opensearch.client.util.ObjectBuilder;
54+
import org.opensearch.client.util.ObjectBuilderBase;
55+
import org.opensearch.client.util.ToCopyableBuilder;
56+
57+
// typedef: _types.ShardSearchFailure
58+
59+
/**
60+
* Represents a failure to search on a specific shard. Used in search responses.
61+
*/
62+
@JsonpDeserializable
63+
@Generated("org.opensearch.client.codegen.CodeGenerator")
64+
public class ShardSearchFailure implements PlainJsonSerializable, ToCopyableBuilder<ShardSearchFailure.Builder, ShardSearchFailure> {
65+
66+
@Nullable
67+
private final String index;
68+
69+
@Nullable
70+
private final String node;
71+
72+
@Nonnull
73+
private final ErrorCause reason;
74+
75+
private final int shard;
76+
77+
// ---------------------------------------------------------------------------------------------
78+
79+
private ShardSearchFailure(Builder builder) {
80+
this.index = builder.index;
81+
this.node = builder.node;
82+
this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason");
83+
this.shard = ApiTypeHelper.requireNonNull(builder.shard, this, "shard");
84+
}
85+
86+
public static ShardSearchFailure of(Function<ShardSearchFailure.Builder, ObjectBuilder<ShardSearchFailure>> fn) {
87+
return fn.apply(new Builder()).build();
88+
}
89+
90+
/**
91+
* The index name where the failure occurred.
92+
* <p>
93+
* API name: {@code index}
94+
* </p>
95+
*/
96+
@Nullable
97+
public final String index() {
98+
return this.index;
99+
}
100+
101+
/**
102+
* The node id where the failure occurred.
103+
* <p>
104+
* API name: {@code node}
105+
* </p>
106+
*/
107+
@Nullable
108+
public final String node() {
109+
return this.node;
110+
}
111+
112+
/**
113+
* Required - API name: {@code reason}
114+
*/
115+
@Nonnull
116+
public final ErrorCause reason() {
117+
return this.reason;
118+
}
119+
120+
/**
121+
* Required - The shard id where the failure occurred.
122+
* <p>
123+
* API name: {@code shard}
124+
* </p>
125+
*/
126+
public final int shard() {
127+
return this.shard;
128+
}
129+
130+
/**
131+
* Serialize this object to JSON.
132+
*/
133+
@Override
134+
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
135+
generator.writeStartObject();
136+
serializeInternal(generator, mapper);
137+
generator.writeEnd();
138+
}
139+
140+
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
141+
if (this.index != null) {
142+
generator.writeKey("index");
143+
generator.write(this.index);
144+
}
145+
146+
if (this.node != null) {
147+
generator.writeKey("node");
148+
generator.write(this.node);
149+
}
150+
151+
generator.writeKey("reason");
152+
this.reason.serialize(generator, mapper);
153+
154+
generator.writeKey("shard");
155+
generator.write(this.shard);
156+
}
157+
158+
// ---------------------------------------------------------------------------------------------
159+
160+
@Override
161+
@Nonnull
162+
public Builder toBuilder() {
163+
return new Builder(this);
164+
}
165+
166+
@Nonnull
167+
public static Builder builder() {
168+
return new Builder();
169+
}
170+
171+
/**
172+
* Builder for {@link ShardSearchFailure}.
173+
*/
174+
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, ShardSearchFailure> {
175+
@Nullable
176+
private String index;
177+
@Nullable
178+
private String node;
179+
private ErrorCause reason;
180+
private Integer shard;
181+
182+
public Builder() {}
183+
184+
private Builder(ShardSearchFailure o) {
185+
this.index = o.index;
186+
this.node = o.node;
187+
this.reason = o.reason;
188+
this.shard = o.shard;
189+
}
190+
191+
private Builder(Builder o) {
192+
this.index = o.index;
193+
this.node = o.node;
194+
this.reason = o.reason;
195+
this.shard = o.shard;
196+
}
197+
198+
@Override
199+
@Nonnull
200+
public Builder copy() {
201+
return new Builder(this);
202+
}
203+
204+
/**
205+
* The index name where the failure occurred.
206+
* <p>
207+
* API name: {@code index}
208+
* </p>
209+
*/
210+
@Nonnull
211+
public final Builder index(@Nullable String value) {
212+
this.index = value;
213+
return this;
214+
}
215+
216+
/**
217+
* The node id where the failure occurred.
218+
* <p>
219+
* API name: {@code node}
220+
* </p>
221+
*/
222+
@Nonnull
223+
public final Builder node(@Nullable String value) {
224+
this.node = value;
225+
return this;
226+
}
227+
228+
/**
229+
* Required - API name: {@code reason}
230+
*/
231+
@Nonnull
232+
public final Builder reason(ErrorCause value) {
233+
this.reason = value;
234+
return this;
235+
}
236+
237+
/**
238+
* Required - API name: {@code reason}
239+
*/
240+
@Nonnull
241+
public final Builder reason(Function<ErrorCause.Builder, ObjectBuilder<ErrorCause>> fn) {
242+
return reason(fn.apply(new ErrorCause.Builder()).build());
243+
}
244+
245+
/**
246+
* Required - The shard id where the failure occurred.
247+
* <p>
248+
* API name: {@code shard}
249+
* </p>
250+
*/
251+
@Nonnull
252+
public final Builder shard(int value) {
253+
this.shard = value;
254+
return this;
255+
}
256+
257+
/**
258+
* Builds a {@link ShardSearchFailure}.
259+
*
260+
* @throws NullPointerException if some of the required fields are null.
261+
*/
262+
@Override
263+
@Nonnull
264+
public ShardSearchFailure build() {
265+
_checkSingleUse();
266+
267+
return new ShardSearchFailure(this);
268+
}
269+
}
270+
271+
// ---------------------------------------------------------------------------------------------
272+
273+
/**
274+
* Json deserializer for {@link ShardSearchFailure}
275+
*/
276+
public static final JsonpDeserializer<ShardSearchFailure> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
277+
Builder::new,
278+
ShardSearchFailure::setupShardSearchFailureDeserializer
279+
);
280+
281+
protected static void setupShardSearchFailureDeserializer(ObjectDeserializer<ShardSearchFailure.Builder> op) {
282+
op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index");
283+
op.add(Builder::node, JsonpDeserializer.stringDeserializer(), "node");
284+
op.add(Builder::reason, ErrorCause._DESERIALIZER, "reason");
285+
op.add(Builder::shard, JsonpDeserializer.integerDeserializer(), "shard");
286+
}
287+
288+
@Override
289+
public int hashCode() {
290+
int result = 17;
291+
result = 31 * result + Objects.hashCode(this.index);
292+
result = 31 * result + Objects.hashCode(this.node);
293+
result = 31 * result + this.reason.hashCode();
294+
result = 31 * result + Integer.hashCode(this.shard);
295+
return result;
296+
}
297+
298+
@Override
299+
public boolean equals(Object o) {
300+
if (this == o) return true;
301+
if (o == null || this.getClass() != o.getClass()) return false;
302+
ShardSearchFailure other = (ShardSearchFailure) o;
303+
return Objects.equals(this.index, other.index)
304+
&& Objects.equals(this.node, other.node)
305+
&& this.reason.equals(other.reason)
306+
&& this.shard == other.shard;
307+
}
308+
}

java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardStatistics.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class ShardStatistics implements PlainJsonSerializable, ToCopyableBuilder
6464
private final int failed;
6565

6666
@Nonnull
67-
private final List<ShardFailure> failures;
67+
private final List<ShardSearchFailure> failures;
6868

6969
@Nullable
7070
private final Integer skipped;
@@ -98,7 +98,7 @@ public final int failed() {
9898
* API name: {@code failures}
9999
*/
100100
@Nonnull
101-
public final List<ShardFailure> failures() {
101+
public final List<ShardSearchFailure> failures() {
102102
return this.failures;
103103
}
104104

@@ -141,7 +141,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
141141
if (ApiTypeHelper.isDefined(this.failures)) {
142142
generator.writeKey("failures");
143143
generator.writeStartArray();
144-
for (ShardFailure item0 : this.failures) {
144+
for (ShardSearchFailure item0 : this.failures) {
145145
item0.serialize(generator, mapper);
146146
}
147147
generator.writeEnd();
@@ -178,7 +178,7 @@ public static Builder builder() {
178178
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, ShardStatistics> {
179179
private Integer failed;
180180
@Nullable
181-
private List<ShardFailure> failures;
181+
private List<ShardSearchFailure> failures;
182182
@Nullable
183183
private Integer skipped;
184184
private Integer successful;
@@ -225,7 +225,7 @@ public final Builder failed(int value) {
225225
* </p>
226226
*/
227227
@Nonnull
228-
public final Builder failures(List<ShardFailure> list) {
228+
public final Builder failures(List<ShardSearchFailure> list) {
229229
this.failures = _listAddAll(this.failures, list);
230230
return this;
231231
}
@@ -238,7 +238,7 @@ public final Builder failures(List<ShardFailure> list) {
238238
* </p>
239239
*/
240240
@Nonnull
241-
public final Builder failures(ShardFailure value, ShardFailure... values) {
241+
public final Builder failures(ShardSearchFailure value, ShardSearchFailure... values) {
242242
this.failures = _listAdd(this.failures, value, values);
243243
return this;
244244
}
@@ -251,8 +251,8 @@ public final Builder failures(ShardFailure value, ShardFailure... values) {
251251
* </p>
252252
*/
253253
@Nonnull
254-
public final Builder failures(Function<ShardFailure.Builder, ObjectBuilder<ShardFailure>> fn) {
255-
return failures(fn.apply(new ShardFailure.Builder()).build());
254+
public final Builder failures(Function<ShardSearchFailure.Builder, ObjectBuilder<ShardSearchFailure>> fn) {
255+
return failures(fn.apply(new ShardSearchFailure.Builder()).build());
256256
}
257257

258258
/**
@@ -308,7 +308,7 @@ public ShardStatistics build() {
308308

309309
protected static void setupShardStatisticsDeserializer(ObjectDeserializer<ShardStatistics.Builder> op) {
310310
op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed");
311-
op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(ShardFailure._DESERIALIZER), "failures");
311+
op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(ShardSearchFailure._DESERIALIZER), "failures");
312312
op.add(Builder::skipped, JsonpDeserializer.integerDeserializer(), "skipped");
313313
op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful");
314314
op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total");

0 commit comments

Comments
 (0)