-
Notifications
You must be signed in to change notification settings - Fork 298
Expand file tree
/
Copy pathHealthRequest.java
More file actions
396 lines (348 loc) · 11.9 KB
/
Copy pathHealthRequest.java
File metadata and controls
396 lines (348 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.clients.elasticsearch.cat;
import co.elastic.clients.elasticsearch._types.Bytes;
import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.elasticsearch._types.TimeUnit;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.transport.Endpoint;
import co.elastic.clients.transport.endpoints.SimpleEndpoint;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.Boolean;
import java.lang.String;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------------------
//
// This code is generated from the Elasticsearch API specification
// at https://github.com/elastic/elasticsearch-specification
//
// Manual updates to this file will be lost when the code is
// re-generated.
//
// If you find a property that is missing or wrongly typed, please
// open an issue or a PR on the API specification repository.
//
//----------------------------------------------------------------
// typedef: cat.health.Request
/**
* Get the cluster health status.
* <p>
* IMPORTANT: CAT APIs are only intended for human consumption using the command
* line or Kibana console. They are not intended for use by applications. For
* application consumption, use the cluster health API. This API is often used
* to check malfunctioning clusters. To help you track cluster health alongside
* log files and alerting systems, the API returns timestamps in two formats:
* <code>HH:MM:SS</code>, which is human-readable but includes no date
* information; <code>Unix epoch time</code>, which is machine-sortable and
* includes date information. The latter format is useful for cluster recoveries
* that take multiple days. You can use the cat health API to verify cluster
* health across multiple nodes. You also can use the API to track the recovery
* of a large cluster over a longer period of time.
*
* @see <a href="../doc-files/api-spec.html#cat.health.Request">API
* specification</a>
*/
public class HealthRequest extends CatRequestBase {
@Nullable
private final Bytes bytes;
private final List<String> h;
private final List<String> s;
@Nullable
private final TimeUnit time;
@Nullable
private final Boolean ts;
// ---------------------------------------------------------------------------------------------
private HealthRequest(Builder builder) {
this.bytes = builder.bytes;
this.h = ApiTypeHelper.unmodifiable(builder.h);
this.s = ApiTypeHelper.unmodifiable(builder.s);
this.time = builder.time;
this.ts = builder.ts;
}
public static HealthRequest of(Function<Builder, ObjectBuilder<HealthRequest>> fn) {
return fn.apply(new Builder()).build();
}
/**
* Sets the units for columns that contain a byte-size value. Note that
* byte-size value units work in terms of powers of 1024. For instance
* <code>1kb</code> means 1024 bytes, not 1000 bytes. If omitted, byte-size
* values are rendered with a suffix such as <code>kb</code>, <code>mb</code>,
* or <code>gb</code>, chosen such that the numeric value of the column is as
* small as possible whilst still being at least <code>1.0</code>. If given,
* byte-size values are rendered as an integer with no suffix, representing the
* value of the column in the chosen unit. Values that are not an exact multiple
* of the chosen unit are rounded down.
* <p>
* API name: {@code bytes}
*/
@Nullable
public final Bytes bytes() {
return this.bytes;
}
/**
* A comma-separated list of columns names to display. It supports simple
* wildcards.
* <p>
* API name: {@code h}
*/
public final List<String> h() {
return this.h;
}
/**
* List of columns that determine how the table should be sorted. Sorting
* defaults to ascending and can be changed by setting <code>:asc</code> or
* <code>:desc</code> as a suffix to the column name.
* <p>
* API name: {@code s}
*/
public final List<String> s() {
return this.s;
}
/**
* Sets the units for columns that contain a time duration. If omitted, time
* duration values are rendered with a suffix such as <code>ms</code>,
* <code>s</code>, <code>m</code> or <code>h</code>, chosen such that the
* numeric value of the column is as small as possible whilst still being at
* least <code>1.0</code>. If given, time duration values are rendered as an
* integer with no suffix. Values that are not an exact multiple of the chosen
* unit are rounded down.
* <p>
* API name: {@code time}
*/
@Nullable
public final TimeUnit time() {
return this.time;
}
/**
* If true, returns <code>HH:MM:SS</code> and Unix epoch timestamps.
* <p>
* API name: {@code ts}
*/
@Nullable
public final Boolean ts() {
return this.ts;
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link HealthRequest}.
*/
public static class Builder extends CatRequestBase.AbstractBuilder<Builder>
implements
ObjectBuilder<HealthRequest> {
@Nullable
private Bytes bytes;
@Nullable
private List<String> h;
@Nullable
private List<String> s;
@Nullable
private TimeUnit time;
@Nullable
private Boolean ts;
public Builder() {
}
private Builder(HealthRequest instance) {
this.bytes = instance.bytes;
this.h = instance.h;
this.s = instance.s;
this.time = instance.time;
this.ts = instance.ts;
}
/**
* Sets the units for columns that contain a byte-size value. Note that
* byte-size value units work in terms of powers of 1024. For instance
* <code>1kb</code> means 1024 bytes, not 1000 bytes. If omitted, byte-size
* values are rendered with a suffix such as <code>kb</code>, <code>mb</code>,
* or <code>gb</code>, chosen such that the numeric value of the column is as
* small as possible whilst still being at least <code>1.0</code>. If given,
* byte-size values are rendered as an integer with no suffix, representing the
* value of the column in the chosen unit. Values that are not an exact multiple
* of the chosen unit are rounded down.
* <p>
* API name: {@code bytes}
*/
public final Builder bytes(@Nullable Bytes value) {
this.bytes = value;
return this;
}
/**
* A comma-separated list of columns names to display. It supports simple
* wildcards.
* <p>
* API name: {@code h}
* <p>
* Adds all elements of <code>list</code> to <code>h</code>.
*/
public final Builder h(List<String> list) {
this.h = _listAddAll(this.h, list);
return this;
}
/**
* A comma-separated list of columns names to display. It supports simple
* wildcards.
* <p>
* API name: {@code h}
* <p>
* Adds one or more values to <code>h</code>.
*/
public final Builder h(String value, String... values) {
this.h = _listAdd(this.h, value, values);
return this;
}
/**
* A comma-separated list of columns names to display. It supports simple
* wildcards.
* <p>
* API name: {@code h}
* <p>
* Adds one or more enum values to <code>h</code>.
*/
public final Builder h(CatHealthColumn value, CatHealthColumn... values) {
this.h = _listAdd(this.h, value.jsonValue(),
Arrays.stream(values).map(CatHealthColumn::jsonValue).toArray(String[]::new));
return this;
}
/**
* List of columns that determine how the table should be sorted. Sorting
* defaults to ascending and can be changed by setting <code>:asc</code> or
* <code>:desc</code> as a suffix to the column name.
* <p>
* API name: {@code s}
* <p>
* Adds all elements of <code>list</code> to <code>s</code>.
*/
public final Builder s(List<String> list) {
this.s = _listAddAll(this.s, list);
return this;
}
/**
* List of columns that determine how the table should be sorted. Sorting
* defaults to ascending and can be changed by setting <code>:asc</code> or
* <code>:desc</code> as a suffix to the column name.
* <p>
* API name: {@code s}
* <p>
* Adds one or more values to <code>s</code>.
*/
public final Builder s(String value, String... values) {
this.s = _listAdd(this.s, value, values);
return this;
}
/**
* Sets the units for columns that contain a time duration. If omitted, time
* duration values are rendered with a suffix such as <code>ms</code>,
* <code>s</code>, <code>m</code> or <code>h</code>, chosen such that the
* numeric value of the column is as small as possible whilst still being at
* least <code>1.0</code>. If given, time duration values are rendered as an
* integer with no suffix. Values that are not an exact multiple of the chosen
* unit are rounded down.
* <p>
* API name: {@code time}
*/
public final Builder time(@Nullable TimeUnit value) {
this.time = value;
return this;
}
/**
* If true, returns <code>HH:MM:SS</code> and Unix epoch timestamps.
* <p>
* API name: {@code ts}
*/
public final Builder ts(@Nullable Boolean value) {
this.ts = value;
return this;
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link HealthRequest}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public HealthRequest build() {
_checkSingleUse();
return new HealthRequest(this);
}
}
/**
* @return New {@link Builder} initialized with field values of this instance
*/
public Builder rebuild() {
return new Builder(this);
}
// ---------------------------------------------------------------------------------------------
/**
* Endpoint "{@code cat.health}".
*/
public static final Endpoint<HealthRequest, HealthResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(
"es/cat.health",
// Request method
request -> {
return "GET";
},
// Request path
request -> {
return "/_cat/health";
},
// Path parameters
request -> {
return Collections.emptyMap();
},
// Request parameters
request -> {
Map<String, String> params = new HashMap<>();
params.put("format", "json");
if (ApiTypeHelper.isDefined(request.s)) {
params.put("s",
request.s.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
}
if (request.bytes != null) {
params.put("bytes", request.bytes.jsonValue());
}
if (ApiTypeHelper.isDefined(request.h)) {
params.put("h",
request.h.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
}
if (request.time != null) {
params.put("time", request.time.jsonValue());
}
if (request.ts != null) {
params.put("ts", String.valueOf(request.ts));
}
return params;
}, SimpleEndpoint.emptyMap(), false, HealthResponse._DESERIALIZER);
}