co.elastic.clients.elasticsearch.cluster.health.IndexHealthStats 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.cluster.health;
import co.elastic.clients.elasticsearch._types.HealthStatus;
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.Integer;
import java.lang.String;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
// typedef: cluster.health.IndexHealthStats
/**
*
* @see API
* specification
*/
@JsonpDeserializable
public class IndexHealthStats implements JsonpSerializable {
private final int activePrimaryShards;
private final int activeShards;
private final int initializingShards;
private final int numberOfReplicas;
private final int numberOfShards;
private final int relocatingShards;
private final Map shards;
private final HealthStatus status;
private final int unassignedShards;
// ---------------------------------------------------------------------------------------------
private IndexHealthStats(Builder builder) {
this.activePrimaryShards = ApiTypeHelper.requireNonNull(builder.activePrimaryShards, this,
"activePrimaryShards");
this.activeShards = ApiTypeHelper.requireNonNull(builder.activeShards, this, "activeShards");
this.initializingShards = ApiTypeHelper.requireNonNull(builder.initializingShards, this, "initializingShards");
this.numberOfReplicas = ApiTypeHelper.requireNonNull(builder.numberOfReplicas, this, "numberOfReplicas");
this.numberOfShards = ApiTypeHelper.requireNonNull(builder.numberOfShards, this, "numberOfShards");
this.relocatingShards = ApiTypeHelper.requireNonNull(builder.relocatingShards, this, "relocatingShards");
this.shards = ApiTypeHelper.unmodifiable(builder.shards);
this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status");
this.unassignedShards = ApiTypeHelper.requireNonNull(builder.unassignedShards, this, "unassignedShards");
}
public static IndexHealthStats of(Function> fn) {
return fn.apply(new Builder()).build();
}
/**
* Required - API name: {@code active_primary_shards}
*/
public final int activePrimaryShards() {
return this.activePrimaryShards;
}
/**
* Required - API name: {@code active_shards}
*/
public final int activeShards() {
return this.activeShards;
}
/**
* Required - API name: {@code initializing_shards}
*/
public final int initializingShards() {
return this.initializingShards;
}
/**
* Required - API name: {@code number_of_replicas}
*/
public final int numberOfReplicas() {
return this.numberOfReplicas;
}
/**
* Required - API name: {@code number_of_shards}
*/
public final int numberOfShards() {
return this.numberOfShards;
}
/**
* Required - API name: {@code relocating_shards}
*/
public final int relocatingShards() {
return this.relocatingShards;
}
/**
* API name: {@code shards}
*/
public final Map shards() {
return this.shards;
}
/**
* Required - API name: {@code status}
*/
public final HealthStatus status() {
return this.status;
}
/**
* Required - API name: {@code unassigned_shards}
*/
public final int unassignedShards() {
return this.unassignedShards;
}
/**
* 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) {
generator.writeKey("active_primary_shards");
generator.write(this.activePrimaryShards);
generator.writeKey("active_shards");
generator.write(this.activeShards);
generator.writeKey("initializing_shards");
generator.write(this.initializingShards);
generator.writeKey("number_of_replicas");
generator.write(this.numberOfReplicas);
generator.writeKey("number_of_shards");
generator.write(this.numberOfShards);
generator.writeKey("relocating_shards");
generator.write(this.relocatingShards);
if (ApiTypeHelper.isDefined(this.shards)) {
generator.writeKey("shards");
generator.writeStartObject();
for (Map.Entry item0 : this.shards.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);
}
generator.writeEnd();
}
generator.writeKey("status");
this.status.serialize(generator, mapper);
generator.writeKey("unassigned_shards");
generator.write(this.unassignedShards);
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link IndexHealthStats}.
*/
public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder {
private Integer activePrimaryShards;
private Integer activeShards;
private Integer initializingShards;
private Integer numberOfReplicas;
private Integer numberOfShards;
private Integer relocatingShards;
@Nullable
private Map shards;
private HealthStatus status;
private Integer unassignedShards;
/**
* Required - API name: {@code active_primary_shards}
*/
public final Builder activePrimaryShards(int value) {
this.activePrimaryShards = value;
return this;
}
/**
* Required - API name: {@code active_shards}
*/
public final Builder activeShards(int value) {
this.activeShards = value;
return this;
}
/**
* Required - API name: {@code initializing_shards}
*/
public final Builder initializingShards(int value) {
this.initializingShards = value;
return this;
}
/**
* Required - API name: {@code number_of_replicas}
*/
public final Builder numberOfReplicas(int value) {
this.numberOfReplicas = value;
return this;
}
/**
* Required - API name: {@code number_of_shards}
*/
public final Builder numberOfShards(int value) {
this.numberOfShards = value;
return this;
}
/**
* Required - API name: {@code relocating_shards}
*/
public final Builder relocatingShards(int value) {
this.relocatingShards = value;
return this;
}
/**
* API name: {@code shards}
*
* Adds all entries of map
to shards
.
*/
public final Builder shards(Map map) {
this.shards = _mapPutAll(this.shards, map);
return this;
}
/**
* API name: {@code shards}
*
* Adds an entry to shards
.
*/
public final Builder shards(String key, ShardHealthStats value) {
this.shards = _mapPut(this.shards, key, value);
return this;
}
/**
* API name: {@code shards}
*
* Adds an entry to shards
using a builder lambda.
*/
public final Builder shards(String key,
Function> fn) {
return shards(key, fn.apply(new ShardHealthStats.Builder()).build());
}
/**
* Required - API name: {@code status}
*/
public final Builder status(HealthStatus value) {
this.status = value;
return this;
}
/**
* Required - API name: {@code unassigned_shards}
*/
public final Builder unassignedShards(int value) {
this.unassignedShards = value;
return this;
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link IndexHealthStats}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public IndexHealthStats build() {
_checkSingleUse();
return new IndexHealthStats(this);
}
}
// ---------------------------------------------------------------------------------------------
/**
* Json deserializer for {@link IndexHealthStats}
*/
public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new,
IndexHealthStats::setupIndexHealthStatsDeserializer);
protected static void setupIndexHealthStatsDeserializer(ObjectDeserializer op) {
op.add(Builder::activePrimaryShards, JsonpDeserializer.integerDeserializer(), "active_primary_shards");
op.add(Builder::activeShards, JsonpDeserializer.integerDeserializer(), "active_shards");
op.add(Builder::initializingShards, JsonpDeserializer.integerDeserializer(), "initializing_shards");
op.add(Builder::numberOfReplicas, JsonpDeserializer.integerDeserializer(), "number_of_replicas");
op.add(Builder::numberOfShards, JsonpDeserializer.integerDeserializer(), "number_of_shards");
op.add(Builder::relocatingShards, JsonpDeserializer.integerDeserializer(), "relocating_shards");
op.add(Builder::shards, JsonpDeserializer.stringMapDeserializer(ShardHealthStats._DESERIALIZER), "shards");
op.add(Builder::status, HealthStatus._DESERIALIZER, "status");
op.add(Builder::unassignedShards, JsonpDeserializer.integerDeserializer(), "unassigned_shards");
}
}