co.elastic.clients.elasticsearch.fleet.FleetSearchResponse 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.
*/
package co.elastic.clients.elasticsearch.fleet;
import co.elastic.clients.elasticsearch._types.ClusterStatistics;
import co.elastic.clients.elasticsearch._types.ShardStatistics;
import co.elastic.clients.elasticsearch._types.aggregations.Aggregate;
import co.elastic.clients.elasticsearch.core.search.HitsMetadata;
import co.elastic.clients.elasticsearch.core.search.Profile;
import co.elastic.clients.elasticsearch.core.search.Suggestion;
import co.elastic.clients.json.ExternallyTaggedUnion;
import co.elastic.clients.json.JsonData;
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.JsonpSerializer;
import co.elastic.clients.json.JsonpUtils;
import co.elastic.clients.json.NamedDeserializer;
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.Boolean;
import java.lang.Double;
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 java.util.function.Supplier;
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: fleet.search.Response
/**
*
* @see API
* specification
*/
@JsonpDeserializable
public class FleetSearchResponse implements JsonpSerializable {
private final long took;
private final boolean timedOut;
private final ShardStatistics shards;
private final HitsMetadata hits;
private final Map aggregations;
@Nullable
private final ClusterStatistics clusters;
private final Map fields;
@Nullable
private final Double maxScore;
@Nullable
private final Long numReducePhases;
@Nullable
private final Profile profile;
@Nullable
private final String pitId;
@Nullable
private final String scrollId;
private final Map>> suggest;
@Nullable
private final Boolean terminatedEarly;
@Nullable
private final JsonpSerializer tDocumentSerializer;
// ---------------------------------------------------------------------------------------------
private FleetSearchResponse(Builder builder) {
this.took = ApiTypeHelper.requireNonNull(builder.took, this, "took");
this.timedOut = ApiTypeHelper.requireNonNull(builder.timedOut, this, "timedOut");
this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards");
this.hits = ApiTypeHelper.requireNonNull(builder.hits, this, "hits");
this.aggregations = ApiTypeHelper.unmodifiable(builder.aggregations);
this.clusters = builder.clusters;
this.fields = ApiTypeHelper.unmodifiable(builder.fields);
this.maxScore = builder.maxScore;
this.numReducePhases = builder.numReducePhases;
this.profile = builder.profile;
this.pitId = builder.pitId;
this.scrollId = builder.scrollId;
this.suggest = ApiTypeHelper.unmodifiable(builder.suggest);
this.terminatedEarly = builder.terminatedEarly;
this.tDocumentSerializer = builder.tDocumentSerializer;
}
public static FleetSearchResponse of(
Function, ObjectBuilder>> fn) {
return fn.apply(new Builder<>()).build();
}
/**
* Required - API name: {@code took}
*/
public final long took() {
return this.took;
}
/**
* Required - API name: {@code timed_out}
*/
public final boolean timedOut() {
return this.timedOut;
}
/**
* Required - API name: {@code _shards}
*/
public final ShardStatistics shards() {
return this.shards;
}
/**
* Required - API name: {@code hits}
*/
public final HitsMetadata hits() {
return this.hits;
}
/**
* API name: {@code aggregations}
*/
public final Map aggregations() {
return this.aggregations;
}
/**
* API name: {@code _clusters}
*/
@Nullable
public final ClusterStatistics clusters() {
return this.clusters;
}
/**
* API name: {@code fields}
*/
public final Map fields() {
return this.fields;
}
/**
* API name: {@code max_score}
*/
@Nullable
public final Double maxScore() {
return this.maxScore;
}
/**
* API name: {@code num_reduce_phases}
*/
@Nullable
public final Long numReducePhases() {
return this.numReducePhases;
}
/**
* API name: {@code profile}
*/
@Nullable
public final Profile profile() {
return this.profile;
}
/**
* API name: {@code pit_id}
*/
@Nullable
public final String pitId() {
return this.pitId;
}
/**
* API name: {@code _scroll_id}
*/
@Nullable
public final String scrollId() {
return this.scrollId;
}
/**
* API name: {@code suggest}
*/
public final Map>> suggest() {
return this.suggest;
}
/**
* API name: {@code terminated_early}
*/
@Nullable
public final Boolean terminatedEarly() {
return this.terminatedEarly;
}
/**
* 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("took");
generator.write(this.took);
generator.writeKey("timed_out");
generator.write(this.timedOut);
generator.writeKey("_shards");
this.shards.serialize(generator, mapper);
generator.writeKey("hits");
this.hits.serialize(generator, mapper);
if (ApiTypeHelper.isDefined(this.aggregations)) {
generator.writeKey("aggregations");
ExternallyTaggedUnion.serializeTypedKeys(this.aggregations, generator, mapper);
}
if (this.clusters != null) {
generator.writeKey("_clusters");
this.clusters.serialize(generator, mapper);
}
if (ApiTypeHelper.isDefined(this.fields)) {
generator.writeKey("fields");
generator.writeStartObject();
for (Map.Entry item0 : this.fields.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);
}
generator.writeEnd();
}
if (this.maxScore != null) {
generator.writeKey("max_score");
generator.write(this.maxScore);
}
if (this.numReducePhases != null) {
generator.writeKey("num_reduce_phases");
generator.write(this.numReducePhases);
}
if (this.profile != null) {
generator.writeKey("profile");
this.profile.serialize(generator, mapper);
}
if (this.pitId != null) {
generator.writeKey("pit_id");
generator.write(this.pitId);
}
if (this.scrollId != null) {
generator.writeKey("_scroll_id");
generator.write(this.scrollId);
}
if (ApiTypeHelper.isDefined(this.suggest)) {
generator.writeKey("suggest");
ExternallyTaggedUnion.serializeTypedKeysArray(this.suggest, generator, mapper);
}
if (this.terminatedEarly != null) {
generator.writeKey("terminated_early");
generator.write(this.terminatedEarly);
}
}
@Override
public String toString() {
return JsonpUtils.toString(this);
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link FleetSearchResponse}.
*/
public static class Builder extends WithJsonObjectBuilderBase>
implements
ObjectBuilder> {
private Long took;
private Boolean timedOut;
private ShardStatistics shards;
private HitsMetadata hits;
@Nullable
private Map aggregations;
@Nullable
private ClusterStatistics clusters;
@Nullable
private Map fields;
@Nullable
private Double maxScore;
@Nullable
private Long numReducePhases;
@Nullable
private Profile profile;
@Nullable
private String pitId;
@Nullable
private String scrollId;
@Nullable
private Map>> suggest;
@Nullable
private Boolean terminatedEarly;
@Nullable
private JsonpSerializer tDocumentSerializer;
/**
* Required - API name: {@code took}
*/
public final Builder took(long value) {
this.took = value;
return this;
}
/**
* Required - API name: {@code timed_out}
*/
public final Builder timedOut(boolean value) {
this.timedOut = value;
return this;
}
/**
* Required - API name: {@code _shards}
*/
public final Builder shards(ShardStatistics value) {
this.shards = value;
return this;
}
/**
* Required - API name: {@code _shards}
*/
public final Builder shards(Function> fn) {
return this.shards(fn.apply(new ShardStatistics.Builder()).build());
}
/**
* Required - API name: {@code hits}
*/
public final Builder hits(HitsMetadata value) {
this.hits = value;
return this;
}
/**
* Required - API name: {@code hits}
*/
public final Builder hits(
Function, ObjectBuilder>> fn) {
return this.hits(fn.apply(new HitsMetadata.Builder()).build());
}
/**
* API name: {@code aggregations}
*
* Adds all entries of map
to aggregations
.
*/
public final Builder aggregations(Map map) {
this.aggregations = _mapPutAll(this.aggregations, map);
return this;
}
/**
* API name: {@code aggregations}
*
* Adds an entry to aggregations
.
*/
public final Builder aggregations(String key, Aggregate value) {
this.aggregations = _mapPut(this.aggregations, key, value);
return this;
}
/**
* API name: {@code aggregations}
*
* Adds an entry to aggregations
using a builder lambda.
*/
public final Builder aggregations(String key,
Function> fn) {
return aggregations(key, fn.apply(new Aggregate.Builder()).build());
}
/**
* API name: {@code _clusters}
*/
public final Builder clusters(@Nullable ClusterStatistics value) {
this.clusters = value;
return this;
}
/**
* API name: {@code _clusters}
*/
public final Builder clusters(
Function> fn) {
return this.clusters(fn.apply(new ClusterStatistics.Builder()).build());
}
/**
* API name: {@code fields}
*
* Adds all entries of map
to fields
.
*/
public final Builder fields(Map map) {
this.fields = _mapPutAll(this.fields, map);
return this;
}
/**
* API name: {@code fields}
*
* Adds an entry to fields
.
*/
public final Builder fields(String key, JsonData value) {
this.fields = _mapPut(this.fields, key, value);
return this;
}
/**
* API name: {@code max_score}
*/
public final Builder maxScore(@Nullable Double value) {
this.maxScore = value;
return this;
}
/**
* API name: {@code num_reduce_phases}
*/
public final Builder numReducePhases(@Nullable Long value) {
this.numReducePhases = value;
return this;
}
/**
* API name: {@code profile}
*/
public final Builder profile(@Nullable Profile value) {
this.profile = value;
return this;
}
/**
* API name: {@code profile}
*/
public final Builder profile(Function> fn) {
return this.profile(fn.apply(new Profile.Builder()).build());
}
/**
* API name: {@code pit_id}
*/
public final Builder pitId(@Nullable String value) {
this.pitId = value;
return this;
}
/**
* API name: {@code _scroll_id}
*/
public final Builder scrollId(@Nullable String value) {
this.scrollId = value;
return this;
}
/**
* API name: {@code suggest}
*
* Adds all entries of map
to suggest
.
*/
public final Builder suggest(Map>> map) {
this.suggest = _mapPutAll(this.suggest, map);
return this;
}
/**
* API name: {@code suggest}
*
* Adds an entry to suggest
.
*/
public final Builder suggest(String key, List> value) {
this.suggest = _mapPut(this.suggest, key, value);
return this;
}
/**
* API name: {@code terminated_early}
*/
public final Builder terminatedEarly(@Nullable Boolean value) {
this.terminatedEarly = value;
return this;
}
/**
* Serializer for TDocument. If not set, an attempt will be made to find a
* serializer from the JSON context.
*/
public final Builder tDocumentSerializer(@Nullable JsonpSerializer value) {
this.tDocumentSerializer = value;
return this;
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link FleetSearchResponse}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public FleetSearchResponse build() {
_checkSingleUse();
return new FleetSearchResponse(this);
}
}
// ---------------------------------------------------------------------------------------------
/**
* Create a JSON deserializer for FleetSearchResponse
*/
public static JsonpDeserializer> createFleetSearchResponseDeserializer(
JsonpDeserializer tDocumentDeserializer) {
return ObjectBuilderDeserializer.createForObject((Supplier>) Builder::new,
op -> FleetSearchResponse.setupFleetSearchResponseDeserializer(op, tDocumentDeserializer));
};
/**
* Json deserializer for {@link FleetSearchResponse} based on named
* deserializers provided by the calling {@code JsonMapper}.
*/
public static final JsonpDeserializer> _DESERIALIZER = JsonpDeserializer
.lazy(() -> createFleetSearchResponseDeserializer(
new NamedDeserializer<>("co.elastic.clients:Deserializer:fleet.search.Response.TDocument")));
protected static void setupFleetSearchResponseDeserializer(
ObjectDeserializer> op,
JsonpDeserializer tDocumentDeserializer) {
op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took");
op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out");
op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards");
op.add(Builder::hits, HitsMetadata.createHitsMetadataDeserializer(tDocumentDeserializer), "hits");
op.add(Builder::aggregations, Aggregate._TYPED_KEYS_DESERIALIZER, "aggregations");
op.add(Builder::clusters, ClusterStatistics._DESERIALIZER, "_clusters");
op.add(Builder::fields, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "fields");
op.add(Builder::maxScore, JsonpDeserializer.doubleDeserializer(), "max_score");
op.add(Builder::numReducePhases, JsonpDeserializer.longDeserializer(), "num_reduce_phases");
op.add(Builder::profile, Profile._DESERIALIZER, "profile");
op.add(Builder::pitId, JsonpDeserializer.stringDeserializer(), "pit_id");
op.add(Builder::scrollId, JsonpDeserializer.stringDeserializer(), "_scroll_id");
op.add(Builder::suggest, ExternallyTaggedUnion.>arrayMapDeserializer(
Suggestion.createSuggestionDeserializer(tDocumentDeserializer)), "suggest");
op.add(Builder::terminatedEarly, JsonpDeserializer.booleanDeserializer(), "terminated_early");
}
}