Skip to content

Commit f256c8d

Browse files
committed
[codegen] Update to latest API spec
1 parent 4b2b4f8 commit f256c8d

File tree

3 files changed

+423
-0
lines changed

3 files changed

+423
-0
lines changed
Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
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+
//----------------------------------------------------
21+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
22+
//----------------------------------------------------
23+
24+
package co.elastic.clients.elasticsearch._types;
25+
26+
import co.elastic.clients.json.JsonpDeserializable;
27+
import co.elastic.clients.json.JsonpDeserializer;
28+
import co.elastic.clients.json.JsonpMapper;
29+
import co.elastic.clients.json.JsonpSerializable;
30+
import co.elastic.clients.json.JsonpUtils;
31+
import co.elastic.clients.json.ObjectBuilderDeserializer;
32+
import co.elastic.clients.json.ObjectDeserializer;
33+
import co.elastic.clients.util.ApiTypeHelper;
34+
import co.elastic.clients.util.ObjectBuilder;
35+
import co.elastic.clients.util.WithJsonObjectBuilderBase;
36+
import jakarta.json.stream.JsonGenerator;
37+
import java.lang.Boolean;
38+
import java.lang.Long;
39+
import java.lang.String;
40+
import java.util.List;
41+
import java.util.Objects;
42+
import java.util.function.Function;
43+
import javax.annotation.Nullable;
44+
45+
// typedef: _types.ClusterDetails
46+
47+
/**
48+
*
49+
* @see <a href="../doc-files/api-spec.html#_types.ClusterDetails">API
50+
* specification</a>
51+
*/
52+
@JsonpDeserializable
53+
public class ClusterDetails implements JsonpSerializable {
54+
private final ClusterSearchStatus status;
55+
56+
private final String indices;
57+
58+
@Nullable
59+
private final Long took;
60+
61+
private final boolean timedOut;
62+
63+
@Nullable
64+
private final ShardStatistics shards;
65+
66+
private final List<ShardFailure> failures;
67+
68+
// ---------------------------------------------------------------------------------------------
69+
70+
private ClusterDetails(Builder builder) {
71+
72+
this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status");
73+
this.indices = ApiTypeHelper.requireNonNull(builder.indices, this, "indices");
74+
this.took = builder.took;
75+
this.timedOut = ApiTypeHelper.requireNonNull(builder.timedOut, this, "timedOut");
76+
this.shards = builder.shards;
77+
this.failures = ApiTypeHelper.unmodifiable(builder.failures);
78+
79+
}
80+
81+
public static ClusterDetails of(Function<Builder, ObjectBuilder<ClusterDetails>> fn) {
82+
return fn.apply(new Builder()).build();
83+
}
84+
85+
/**
86+
* Required - API name: {@code status}
87+
*/
88+
public final ClusterSearchStatus status() {
89+
return this.status;
90+
}
91+
92+
/**
93+
* Required - API name: {@code indices}
94+
*/
95+
public final String indices() {
96+
return this.indices;
97+
}
98+
99+
/**
100+
* API name: {@code took}
101+
*/
102+
@Nullable
103+
public final Long took() {
104+
return this.took;
105+
}
106+
107+
/**
108+
* Required - API name: {@code timed_out}
109+
*/
110+
public final boolean timedOut() {
111+
return this.timedOut;
112+
}
113+
114+
/**
115+
* API name: {@code _shards}
116+
*/
117+
@Nullable
118+
public final ShardStatistics shards() {
119+
return this.shards;
120+
}
121+
122+
/**
123+
* API name: {@code failures}
124+
*/
125+
public final List<ShardFailure> failures() {
126+
return this.failures;
127+
}
128+
129+
/**
130+
* Serialize this object to JSON.
131+
*/
132+
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
133+
generator.writeStartObject();
134+
serializeInternal(generator, mapper);
135+
generator.writeEnd();
136+
}
137+
138+
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
139+
140+
generator.writeKey("status");
141+
this.status.serialize(generator, mapper);
142+
generator.writeKey("indices");
143+
generator.write(this.indices);
144+
145+
if (this.took != null) {
146+
generator.writeKey("took");
147+
generator.write(this.took);
148+
149+
}
150+
generator.writeKey("timed_out");
151+
generator.write(this.timedOut);
152+
153+
if (this.shards != null) {
154+
generator.writeKey("_shards");
155+
this.shards.serialize(generator, mapper);
156+
157+
}
158+
if (ApiTypeHelper.isDefined(this.failures)) {
159+
generator.writeKey("failures");
160+
generator.writeStartArray();
161+
for (ShardFailure item0 : this.failures) {
162+
item0.serialize(generator, mapper);
163+
164+
}
165+
generator.writeEnd();
166+
167+
}
168+
169+
}
170+
171+
@Override
172+
public String toString() {
173+
return JsonpUtils.toString(this);
174+
}
175+
176+
// ---------------------------------------------------------------------------------------------
177+
178+
/**
179+
* Builder for {@link ClusterDetails}.
180+
*/
181+
182+
public static class Builder extends WithJsonObjectBuilderBase<Builder> implements ObjectBuilder<ClusterDetails> {
183+
private ClusterSearchStatus status;
184+
185+
private String indices;
186+
187+
@Nullable
188+
private Long took;
189+
190+
private Boolean timedOut;
191+
192+
@Nullable
193+
private ShardStatistics shards;
194+
195+
@Nullable
196+
private List<ShardFailure> failures;
197+
198+
/**
199+
* Required - API name: {@code status}
200+
*/
201+
public final Builder status(ClusterSearchStatus value) {
202+
this.status = value;
203+
return this;
204+
}
205+
206+
/**
207+
* Required - API name: {@code indices}
208+
*/
209+
public final Builder indices(String value) {
210+
this.indices = value;
211+
return this;
212+
}
213+
214+
/**
215+
* API name: {@code took}
216+
*/
217+
public final Builder took(@Nullable Long value) {
218+
this.took = value;
219+
return this;
220+
}
221+
222+
/**
223+
* Required - API name: {@code timed_out}
224+
*/
225+
public final Builder timedOut(boolean value) {
226+
this.timedOut = value;
227+
return this;
228+
}
229+
230+
/**
231+
* API name: {@code _shards}
232+
*/
233+
public final Builder shards(@Nullable ShardStatistics value) {
234+
this.shards = value;
235+
return this;
236+
}
237+
238+
/**
239+
* API name: {@code _shards}
240+
*/
241+
public final Builder shards(Function<ShardStatistics.Builder, ObjectBuilder<ShardStatistics>> fn) {
242+
return this.shards(fn.apply(new ShardStatistics.Builder()).build());
243+
}
244+
245+
/**
246+
* API name: {@code failures}
247+
* <p>
248+
* Adds all elements of <code>list</code> to <code>failures</code>.
249+
*/
250+
public final Builder failures(List<ShardFailure> list) {
251+
this.failures = _listAddAll(this.failures, list);
252+
return this;
253+
}
254+
255+
/**
256+
* API name: {@code failures}
257+
* <p>
258+
* Adds one or more values to <code>failures</code>.
259+
*/
260+
public final Builder failures(ShardFailure value, ShardFailure... values) {
261+
this.failures = _listAdd(this.failures, value, values);
262+
return this;
263+
}
264+
265+
/**
266+
* API name: {@code failures}
267+
* <p>
268+
* Adds a value to <code>failures</code> using a builder lambda.
269+
*/
270+
public final Builder failures(Function<ShardFailure.Builder, ObjectBuilder<ShardFailure>> fn) {
271+
return failures(fn.apply(new ShardFailure.Builder()).build());
272+
}
273+
274+
@Override
275+
protected Builder self() {
276+
return this;
277+
}
278+
279+
/**
280+
* Builds a {@link ClusterDetails}.
281+
*
282+
* @throws NullPointerException
283+
* if some of the required fields are null.
284+
*/
285+
public ClusterDetails build() {
286+
_checkSingleUse();
287+
288+
return new ClusterDetails(this);
289+
}
290+
}
291+
292+
// ---------------------------------------------------------------------------------------------
293+
294+
/**
295+
* Json deserializer for {@link ClusterDetails}
296+
*/
297+
public static final JsonpDeserializer<ClusterDetails> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new,
298+
ClusterDetails::setupClusterDetailsDeserializer);
299+
300+
protected static void setupClusterDetailsDeserializer(ObjectDeserializer<ClusterDetails.Builder> op) {
301+
302+
op.add(Builder::status, ClusterSearchStatus._DESERIALIZER, "status");
303+
op.add(Builder::indices, JsonpDeserializer.stringDeserializer(), "indices");
304+
op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took");
305+
op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out");
306+
op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards");
307+
op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(ShardFailure._DESERIALIZER), "failures");
308+
309+
}
310+
311+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
//----------------------------------------------------
21+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
22+
//----------------------------------------------------
23+
24+
package co.elastic.clients.elasticsearch._types;
25+
26+
import co.elastic.clients.json.JsonEnum;
27+
import co.elastic.clients.json.JsonpDeserializable;
28+
import co.elastic.clients.json.JsonpDeserializer;
29+
30+
/**
31+
*
32+
* @see <a href="../doc-files/api-spec.html#_types.ClusterSearchStatus">API
33+
* specification</a>
34+
*/
35+
@JsonpDeserializable
36+
public enum ClusterSearchStatus implements JsonEnum {
37+
Running("running"),
38+
39+
Successful("successful"),
40+
41+
Partial("partial"),
42+
43+
Skipped("skipped"),
44+
45+
Failed("failed"),
46+
47+
;
48+
49+
private final String jsonValue;
50+
51+
ClusterSearchStatus(String jsonValue) {
52+
this.jsonValue = jsonValue;
53+
}
54+
55+
public String jsonValue() {
56+
return this.jsonValue;
57+
}
58+
59+
public static final JsonEnum.Deserializer<ClusterSearchStatus> _DESERIALIZER = new JsonEnum.Deserializer<>(
60+
ClusterSearchStatus.values());
61+
}

0 commit comments

Comments
 (0)