co.elastic.clients.elasticsearch.nodes.NodesStatsRequest Maven / Gradle / Ivy
Show all versions of elasticsearch-java Show documentation
/*
* 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.
*/
//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------
package co.elastic.clients.elasticsearch.nodes;
import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.elasticsearch._types.Level;
import co.elastic.clients.elasticsearch._types.RequestBase;
import co.elastic.clients.elasticsearch._types.Time;
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 co.elastic.clients.util.ObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.Boolean;
import java.lang.String;
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;
// typedef: nodes.stats.Request
/**
* Returns statistical information about nodes in the cluster.
*
* @see API
* specification
*/
public class NodesStatsRequest extends RequestBase {
private final List completionFields;
private final List fielddataFields;
private final List fields;
@Nullable
private final Boolean groups;
@Nullable
private final Boolean includeSegmentFileSizes;
@Nullable
private final Boolean includeUnloadedSegments;
private final List indexMetric;
@Nullable
private final Level level;
@Nullable
private final Time masterTimeout;
private final List metric;
private final List nodeId;
@Nullable
private final Time timeout;
private final List types;
// ---------------------------------------------------------------------------------------------
private NodesStatsRequest(Builder builder) {
this.completionFields = ApiTypeHelper.unmodifiable(builder.completionFields);
this.fielddataFields = ApiTypeHelper.unmodifiable(builder.fielddataFields);
this.fields = ApiTypeHelper.unmodifiable(builder.fields);
this.groups = builder.groups;
this.includeSegmentFileSizes = builder.includeSegmentFileSizes;
this.includeUnloadedSegments = builder.includeUnloadedSegments;
this.indexMetric = ApiTypeHelper.unmodifiable(builder.indexMetric);
this.level = builder.level;
this.masterTimeout = builder.masterTimeout;
this.metric = ApiTypeHelper.unmodifiable(builder.metric);
this.nodeId = ApiTypeHelper.unmodifiable(builder.nodeId);
this.timeout = builder.timeout;
this.types = ApiTypeHelper.unmodifiable(builder.types);
}
public static NodesStatsRequest of(Function> fn) {
return fn.apply(new Builder()).build();
}
/**
* Comma-separated list or wildcard expressions of fields to include in
* fielddata and suggest statistics.
*
* API name: {@code completion_fields}
*/
public final List completionFields() {
return this.completionFields;
}
/**
* Comma-separated list or wildcard expressions of fields to include in
* fielddata statistics.
*
* API name: {@code fielddata_fields}
*/
public final List fielddataFields() {
return this.fielddataFields;
}
/**
* Comma-separated list or wildcard expressions of fields to include in the
* statistics.
*
* API name: {@code fields}
*/
public final List fields() {
return this.fields;
}
/**
* Comma-separated list of search groups to include in the search statistics.
*
* API name: {@code groups}
*/
@Nullable
public final Boolean groups() {
return this.groups;
}
/**
* If true, the call reports the aggregated disk usage of each one of the Lucene
* index files (only applies if segment stats are requested).
*
* API name: {@code include_segment_file_sizes}
*/
@Nullable
public final Boolean includeSegmentFileSizes() {
return this.includeSegmentFileSizes;
}
/**
* If set to true segment stats will include stats for segments that are not
* currently loaded into memory
*
* API name: {@code include_unloaded_segments}
*/
@Nullable
public final Boolean includeUnloadedSegments() {
return this.includeUnloadedSegments;
}
/**
* Limit the information returned for indices metric to the specific index
* metrics. It can be used only if indices (or all) metric is specified.
*
* API name: {@code index_metric}
*/
public final List indexMetric() {
return this.indexMetric;
}
/**
* Indicates whether statistics are aggregated at the cluster, index, or shard
* level.
*
* API name: {@code level}
*/
@Nullable
public final Level level() {
return this.level;
}
/**
* Period to wait for a connection to the master node. If no response is
* received before the timeout expires, the request fails and returns an error.
*
* API name: {@code master_timeout}
*/
@Nullable
public final Time masterTimeout() {
return this.masterTimeout;
}
/**
* Limit the information returned to the specified metrics
*
* API name: {@code metric}
*/
public final List metric() {
return this.metric;
}
/**
* Comma-separated list of node IDs or names used to limit returned information.
*
* API name: {@code node_id}
*/
public final List nodeId() {
return this.nodeId;
}
/**
* Period to wait for a response. If no response is received before the timeout
* expires, the request fails and returns an error.
*
* API name: {@code timeout}
*/
@Nullable
public final Time timeout() {
return this.timeout;
}
/**
* A comma-separated list of document types for the indexing index metric.
*
* API name: {@code types}
*/
public final List types() {
return this.types;
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link NodesStatsRequest}.
*/
public static class Builder extends ObjectBuilderBase implements ObjectBuilder {
@Nullable
private List completionFields;
@Nullable
private List fielddataFields;
@Nullable
private List fields;
@Nullable
private Boolean groups;
@Nullable
private Boolean includeSegmentFileSizes;
@Nullable
private Boolean includeUnloadedSegments;
@Nullable
private List indexMetric;
@Nullable
private Level level;
@Nullable
private Time masterTimeout;
@Nullable
private List metric;
@Nullable
private List nodeId;
@Nullable
private Time timeout;
@Nullable
private List types;
/**
* Comma-separated list or wildcard expressions of fields to include in
* fielddata and suggest statistics.
*
* API name: {@code completion_fields}
*
* Adds all elements of list
to completionFields
.
*/
public final Builder completionFields(List list) {
this.completionFields = _listAddAll(this.completionFields, list);
return this;
}
/**
* Comma-separated list or wildcard expressions of fields to include in
* fielddata and suggest statistics.
*
* API name: {@code completion_fields}
*
* Adds one or more values to completionFields
.
*/
public final Builder completionFields(String value, String... values) {
this.completionFields = _listAdd(this.completionFields, value, values);
return this;
}
/**
* Comma-separated list or wildcard expressions of fields to include in
* fielddata statistics.
*
* API name: {@code fielddata_fields}
*
* Adds all elements of list
to fielddataFields
.
*/
public final Builder fielddataFields(List list) {
this.fielddataFields = _listAddAll(this.fielddataFields, list);
return this;
}
/**
* Comma-separated list or wildcard expressions of fields to include in
* fielddata statistics.
*
* API name: {@code fielddata_fields}
*
* Adds one or more values to fielddataFields
.
*/
public final Builder fielddataFields(String value, String... values) {
this.fielddataFields = _listAdd(this.fielddataFields, value, values);
return this;
}
/**
* Comma-separated list or wildcard expressions of fields to include in the
* statistics.
*
* API name: {@code fields}
*
* Adds all elements of list
to fields
.
*/
public final Builder fields(List list) {
this.fields = _listAddAll(this.fields, list);
return this;
}
/**
* Comma-separated list or wildcard expressions of fields to include in the
* statistics.
*
* API name: {@code fields}
*
* Adds one or more values to fields
.
*/
public final Builder fields(String value, String... values) {
this.fields = _listAdd(this.fields, value, values);
return this;
}
/**
* Comma-separated list of search groups to include in the search statistics.
*
* API name: {@code groups}
*/
public final Builder groups(@Nullable Boolean value) {
this.groups = value;
return this;
}
/**
* If true, the call reports the aggregated disk usage of each one of the Lucene
* index files (only applies if segment stats are requested).
*
* API name: {@code include_segment_file_sizes}
*/
public final Builder includeSegmentFileSizes(@Nullable Boolean value) {
this.includeSegmentFileSizes = value;
return this;
}
/**
* If set to true segment stats will include stats for segments that are not
* currently loaded into memory
*
* API name: {@code include_unloaded_segments}
*/
public final Builder includeUnloadedSegments(@Nullable Boolean value) {
this.includeUnloadedSegments = value;
return this;
}
/**
* Limit the information returned for indices metric to the specific index
* metrics. It can be used only if indices (or all) metric is specified.
*
* API name: {@code index_metric}
*
* Adds all elements of list
to indexMetric
.
*/
public final Builder indexMetric(List list) {
this.indexMetric = _listAddAll(this.indexMetric, list);
return this;
}
/**
* Limit the information returned for indices metric to the specific index
* metrics. It can be used only if indices (or all) metric is specified.
*
* API name: {@code index_metric}
*
* Adds one or more values to indexMetric
.
*/
public final Builder indexMetric(String value, String... values) {
this.indexMetric = _listAdd(this.indexMetric, value, values);
return this;
}
/**
* Indicates whether statistics are aggregated at the cluster, index, or shard
* level.
*
* API name: {@code level}
*/
public final Builder level(@Nullable Level value) {
this.level = value;
return this;
}
/**
* Period to wait for a connection to the master node. If no response is
* received before the timeout expires, the request fails and returns an error.
*
* API name: {@code master_timeout}
*/
public final Builder masterTimeout(@Nullable Time value) {
this.masterTimeout = value;
return this;
}
/**
* Period to wait for a connection to the master node. If no response is
* received before the timeout expires, the request fails and returns an error.
*
* API name: {@code master_timeout}
*/
public final Builder masterTimeout(Function> fn) {
return this.masterTimeout(fn.apply(new Time.Builder()).build());
}
/**
* Limit the information returned to the specified metrics
*
* API name: {@code metric}
*
* Adds all elements of list
to metric
.
*/
public final Builder metric(List list) {
this.metric = _listAddAll(this.metric, list);
return this;
}
/**
* Limit the information returned to the specified metrics
*
* API name: {@code metric}
*
* Adds one or more values to metric
.
*/
public final Builder metric(String value, String... values) {
this.metric = _listAdd(this.metric, value, values);
return this;
}
/**
* Comma-separated list of node IDs or names used to limit returned information.
*
* API name: {@code node_id}
*
* Adds all elements of list
to nodeId
.
*/
public final Builder nodeId(List list) {
this.nodeId = _listAddAll(this.nodeId, list);
return this;
}
/**
* Comma-separated list of node IDs or names used to limit returned information.
*
* API name: {@code node_id}
*
* Adds one or more values to nodeId
.
*/
public final Builder nodeId(String value, String... values) {
this.nodeId = _listAdd(this.nodeId, value, values);
return this;
}
/**
* Period to wait for a response. If no response is received before the timeout
* expires, the request fails and returns an error.
*
* API name: {@code timeout}
*/
public final Builder timeout(@Nullable Time value) {
this.timeout = value;
return this;
}
/**
* Period to wait for a response. If no response is received before the timeout
* expires, the request fails and returns an error.
*
* API name: {@code timeout}
*/
public final Builder timeout(Function> fn) {
return this.timeout(fn.apply(new Time.Builder()).build());
}
/**
* A comma-separated list of document types for the indexing index metric.
*
* API name: {@code types}
*
* Adds all elements of list
to types
.
*/
public final Builder types(List list) {
this.types = _listAddAll(this.types, list);
return this;
}
/**
* A comma-separated list of document types for the indexing index metric.
*
* API name: {@code types}
*
* Adds one or more values to types
.
*/
public final Builder types(String value, String... values) {
this.types = _listAdd(this.types, value, values);
return this;
}
/**
* Builds a {@link NodesStatsRequest}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public NodesStatsRequest build() {
_checkSingleUse();
return new NodesStatsRequest(this);
}
}
// ---------------------------------------------------------------------------------------------
/**
* Endpoint "{@code nodes.stats}".
*/
public static final Endpoint _ENDPOINT = new SimpleEndpoint<>(
"es/nodes.stats",
// Request method
request -> {
return "GET";
},
// Request path
request -> {
final int _metric = 1 << 0;
final int _indexMetric = 1 << 1;
final int _nodeId = 1 << 2;
int propsSet = 0;
if (ApiTypeHelper.isDefined(request.metric()))
propsSet |= _metric;
if (ApiTypeHelper.isDefined(request.indexMetric()))
propsSet |= _indexMetric;
if (ApiTypeHelper.isDefined(request.nodeId()))
propsSet |= _nodeId;
if (propsSet == 0) {
StringBuilder buf = new StringBuilder();
buf.append("/_nodes");
buf.append("/stats");
return buf.toString();
}
if (propsSet == (_nodeId)) {
StringBuilder buf = new StringBuilder();
buf.append("/_nodes");
buf.append("/");
SimpleEndpoint.pathEncode(request.nodeId.stream().map(v -> v).collect(Collectors.joining(",")),
buf);
buf.append("/stats");
return buf.toString();
}
if (propsSet == (_metric)) {
StringBuilder buf = new StringBuilder();
buf.append("/_nodes");
buf.append("/stats");
buf.append("/");
SimpleEndpoint.pathEncode(request.metric.stream().map(v -> v).collect(Collectors.joining(",")),
buf);
return buf.toString();
}
if (propsSet == (_nodeId | _metric)) {
StringBuilder buf = new StringBuilder();
buf.append("/_nodes");
buf.append("/");
SimpleEndpoint.pathEncode(request.nodeId.stream().map(v -> v).collect(Collectors.joining(",")),
buf);
buf.append("/stats");
buf.append("/");
SimpleEndpoint.pathEncode(request.metric.stream().map(v -> v).collect(Collectors.joining(",")),
buf);
return buf.toString();
}
if (propsSet == (_metric | _indexMetric)) {
StringBuilder buf = new StringBuilder();
buf.append("/_nodes");
buf.append("/stats");
buf.append("/");
SimpleEndpoint.pathEncode(request.metric.stream().map(v -> v).collect(Collectors.joining(",")),
buf);
buf.append("/");
SimpleEndpoint.pathEncode(request.indexMetric.stream().map(v -> v).collect(Collectors.joining(",")),
buf);
return buf.toString();
}
if (propsSet == (_nodeId | _metric | _indexMetric)) {
StringBuilder buf = new StringBuilder();
buf.append("/_nodes");
buf.append("/");
SimpleEndpoint.pathEncode(request.nodeId.stream().map(v -> v).collect(Collectors.joining(",")),
buf);
buf.append("/stats");
buf.append("/");
SimpleEndpoint.pathEncode(request.metric.stream().map(v -> v).collect(Collectors.joining(",")),
buf);
buf.append("/");
SimpleEndpoint.pathEncode(request.indexMetric.stream().map(v -> v).collect(Collectors.joining(",")),
buf);
return buf.toString();
}
throw SimpleEndpoint.noPathTemplateFound("path");
},
// Request parameters
request -> {
Map params = new HashMap<>();
if (request.masterTimeout != null) {
params.put("master_timeout", request.masterTimeout._toJsonString());
}
if (ApiTypeHelper.isDefined(request.types)) {
params.put("types", request.types.stream().map(v -> v).collect(Collectors.joining(",")));
}
if (request.level != null) {
params.put("level", request.level.jsonValue());
}
if (ApiTypeHelper.isDefined(request.completionFields)) {
params.put("completion_fields",
request.completionFields.stream().map(v -> v).collect(Collectors.joining(",")));
}
if (ApiTypeHelper.isDefined(request.fielddataFields)) {
params.put("fielddata_fields",
request.fielddataFields.stream().map(v -> v).collect(Collectors.joining(",")));
}
if (request.groups != null) {
params.put("groups", String.valueOf(request.groups));
}
if (request.includeUnloadedSegments != null) {
params.put("include_unloaded_segments", String.valueOf(request.includeUnloadedSegments));
}
if (ApiTypeHelper.isDefined(request.fields)) {
params.put("fields", request.fields.stream().map(v -> v).collect(Collectors.joining(",")));
}
if (request.includeSegmentFileSizes != null) {
params.put("include_segment_file_sizes", String.valueOf(request.includeSegmentFileSizes));
}
if (request.timeout != null) {
params.put("timeout", request.timeout._toJsonString());
}
return params;
}, SimpleEndpoint.emptyMap(), false, NodesStatsResponse._DESERIALIZER);
}