co.elastic.clients.elasticsearch.cluster.allocation_explain.ClusterInfo Maven / Gradle / Ivy
/*
* 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.cluster.allocation_explain;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import co.elastic.clients.util.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.Long;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
// typedef: cluster.allocation_explain.ClusterInfo
/**
*
* @see API
* specification
*/
@JsonpDeserializable
public class ClusterInfo implements JsonpSerializable {
private final Map nodes;
private final Map shardSizes;
private final Map shardDataSetSizes;
private final Map shardPaths;
private final List reservedSizes;
// ---------------------------------------------------------------------------------------------
private ClusterInfo(Builder builder) {
this.nodes = ApiTypeHelper.unmodifiableRequired(builder.nodes, this, "nodes");
this.shardSizes = ApiTypeHelper.unmodifiableRequired(builder.shardSizes, this, "shardSizes");
this.shardDataSetSizes = ApiTypeHelper.unmodifiable(builder.shardDataSetSizes);
this.shardPaths = ApiTypeHelper.unmodifiableRequired(builder.shardPaths, this, "shardPaths");
this.reservedSizes = ApiTypeHelper.unmodifiableRequired(builder.reservedSizes, this, "reservedSizes");
}
public static ClusterInfo of(Function> fn) {
return fn.apply(new Builder()).build();
}
/**
* Required - API name: {@code nodes}
*/
public final Map nodes() {
return this.nodes;
}
/**
* Required - API name: {@code shard_sizes}
*/
public final Map shardSizes() {
return this.shardSizes;
}
/**
* API name: {@code shard_data_set_sizes}
*/
public final Map shardDataSetSizes() {
return this.shardDataSetSizes;
}
/**
* Required - API name: {@code shard_paths}
*/
public final Map shardPaths() {
return this.shardPaths;
}
/**
* Required - API name: {@code reserved_sizes}
*/
public final List reservedSizes() {
return this.reservedSizes;
}
/**
* Serialize this object to JSON.
*/
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
if (ApiTypeHelper.isDefined(this.nodes)) {
generator.writeKey("nodes");
generator.writeStartObject();
for (Map.Entry item0 : this.nodes.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.shardSizes)) {
generator.writeKey("shard_sizes");
generator.writeStartObject();
for (Map.Entry item0 : this.shardSizes.entrySet()) {
generator.writeKey(item0.getKey());
generator.write(item0.getValue());
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.shardDataSetSizes)) {
generator.writeKey("shard_data_set_sizes");
generator.writeStartObject();
for (Map.Entry item0 : this.shardDataSetSizes.entrySet()) {
generator.writeKey(item0.getKey());
generator.write(item0.getValue());
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.shardPaths)) {
generator.writeKey("shard_paths");
generator.writeStartObject();
for (Map.Entry item0 : this.shardPaths.entrySet()) {
generator.writeKey(item0.getKey());
generator.write(item0.getValue());
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.reservedSizes)) {
generator.writeKey("reserved_sizes");
generator.writeStartArray();
for (ReservedSize item0 : this.reservedSizes) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link ClusterInfo}.
*/
public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder {
private Map nodes;
private Map shardSizes;
@Nullable
private Map shardDataSetSizes;
private Map shardPaths;
private List reservedSizes;
/**
* Required - API name: {@code nodes}
*
* Adds all entries of map
to nodes
.
*/
public final Builder nodes(Map map) {
this.nodes = _mapPutAll(this.nodes, map);
return this;
}
/**
* Required - API name: {@code nodes}
*
* Adds an entry to nodes
.
*/
public final Builder nodes(String key, NodeDiskUsage value) {
this.nodes = _mapPut(this.nodes, key, value);
return this;
}
/**
* Required - API name: {@code nodes}
*
* Adds an entry to nodes
using a builder lambda.
*/
public final Builder nodes(String key, Function> fn) {
return nodes(key, fn.apply(new NodeDiskUsage.Builder()).build());
}
/**
* Required - API name: {@code shard_sizes}
*
* Adds all entries of map
to shardSizes
.
*/
public final Builder shardSizes(Map map) {
this.shardSizes = _mapPutAll(this.shardSizes, map);
return this;
}
/**
* Required - API name: {@code shard_sizes}
*
* Adds an entry to shardSizes
.
*/
public final Builder shardSizes(String key, Long value) {
this.shardSizes = _mapPut(this.shardSizes, key, value);
return this;
}
/**
* API name: {@code shard_data_set_sizes}
*
* Adds all entries of map
to shardDataSetSizes
.
*/
public final Builder shardDataSetSizes(Map map) {
this.shardDataSetSizes = _mapPutAll(this.shardDataSetSizes, map);
return this;
}
/**
* API name: {@code shard_data_set_sizes}
*
* Adds an entry to shardDataSetSizes
.
*/
public final Builder shardDataSetSizes(String key, String value) {
this.shardDataSetSizes = _mapPut(this.shardDataSetSizes, key, value);
return this;
}
/**
* Required - API name: {@code shard_paths}
*
* Adds all entries of map
to shardPaths
.
*/
public final Builder shardPaths(Map map) {
this.shardPaths = _mapPutAll(this.shardPaths, map);
return this;
}
/**
* Required - API name: {@code shard_paths}
*
* Adds an entry to shardPaths
.
*/
public final Builder shardPaths(String key, String value) {
this.shardPaths = _mapPut(this.shardPaths, key, value);
return this;
}
/**
* Required - API name: {@code reserved_sizes}
*
* Adds all elements of list
to reservedSizes
.
*/
public final Builder reservedSizes(List list) {
this.reservedSizes = _listAddAll(this.reservedSizes, list);
return this;
}
/**
* Required - API name: {@code reserved_sizes}
*
* Adds one or more values to reservedSizes
.
*/
public final Builder reservedSizes(ReservedSize value, ReservedSize... values) {
this.reservedSizes = _listAdd(this.reservedSizes, value, values);
return this;
}
/**
* Required - API name: {@code reserved_sizes}
*
* Adds a value to reservedSizes
using a builder lambda.
*/
public final Builder reservedSizes(Function> fn) {
return reservedSizes(fn.apply(new ReservedSize.Builder()).build());
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link ClusterInfo}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public ClusterInfo build() {
_checkSingleUse();
return new ClusterInfo(this);
}
}
// ---------------------------------------------------------------------------------------------
/**
* Json deserializer for {@link ClusterInfo}
*/
public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new,
ClusterInfo::setupClusterInfoDeserializer);
protected static void setupClusterInfoDeserializer(ObjectDeserializer op) {
op.add(Builder::nodes, JsonpDeserializer.stringMapDeserializer(NodeDiskUsage._DESERIALIZER), "nodes");
op.add(Builder::shardSizes, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.longDeserializer()),
"shard_sizes");
op.add(Builder::shardDataSetSizes,
JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()),
"shard_data_set_sizes");
op.add(Builder::shardPaths, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()),
"shard_paths");
op.add(Builder::reservedSizes, JsonpDeserializer.arrayDeserializer(ReservedSize._DESERIALIZER),
"reserved_sizes");
}
}