diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchAsyncClient.java index b458c37487..d12fd06677 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchAsyncClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchAsyncClient.java @@ -71,6 +71,8 @@ import co.elastic.clients.elasticsearch.core.IndexResponse; import co.elastic.clients.elasticsearch.core.InfoRequest; import co.elastic.clients.elasticsearch.core.InfoResponse; +import co.elastic.clients.elasticsearch.core.KnnEvalRequest; +import co.elastic.clients.elasticsearch.core.KnnEvalResponse; import co.elastic.clients.elasticsearch.core.ListReindexRequest; import co.elastic.clients.elasticsearch.core.ListReindexResponse; import co.elastic.clients.elasticsearch.core.MgetRequest; @@ -3556,6 +3558,83 @@ public CompletableFuture info() { return this.transport.performRequestAsync(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); } + // ----- Endpoint: knn_eval + + /** + * Evaluate kNN search settings. + *

+ * Estimate the recall and cost of approximate kNN search configurations on a + * dense_vector field against a more thorough baseline. The field + * must use the bbq_disk index type, and must not be inside a + * nested object. + *

+ * Each knn_settings entry reports the mean recall of the + * baseline's top k, not of relevance judgments, plus included and + * excluded query counts and cost totals. A query is excluded from the mean + * recall when the candidate finds a document scoring above the baseline's + * lowest top k score. A baseline returning fewer than + * k hits fails that query, because recall at k is + * undefined. All configurations run against one point in time. + *

+ * The default baseline uses a visit_percentage of 20 and a + * rescore_vector.oversample of 100. An exact full-precision + * baseline must be requested explicitly with allow_exact_baseline, + * and is limited to 100 million vector-by-query comparisons. + *

+ * The request is refused when the search.knn_eval.enabled cluster + * setting or the index.knn_eval.enabled index setting is + * false. + * + * @see Documentation + * on elastic.co + */ + + public CompletableFuture knnEval(KnnEvalRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) KnnEvalRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Evaluate kNN search settings. + *

+ * Estimate the recall and cost of approximate kNN search configurations on a + * dense_vector field against a more thorough baseline. The field + * must use the bbq_disk index type, and must not be inside a + * nested object. + *

+ * Each knn_settings entry reports the mean recall of the + * baseline's top k, not of relevance judgments, plus included and + * excluded query counts and cost totals. A query is excluded from the mean + * recall when the candidate finds a document scoring above the baseline's + * lowest top k score. A baseline returning fewer than + * k hits fails that query, because recall at k is + * undefined. All configurations run against one point in time. + *

+ * The default baseline uses a visit_percentage of 20 and a + * rescore_vector.oversample of 100. An exact full-precision + * baseline must be requested explicitly with allow_exact_baseline, + * and is limited to 100 million vector-by-query comparisons. + *

+ * The request is refused when the search.knn_eval.enabled cluster + * setting or the index.knn_eval.enabled index setting is + * false. + * + * @param fn + * a function that initializes a builder to create the + * {@link KnnEvalRequest} + * @see Documentation + * on elastic.co + */ + + public final CompletableFuture knnEval( + Function> fn) { + return knnEval(fn.apply(new KnnEvalRequest.Builder()).build()); + } + // ----- Endpoint: list_reindex /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchClient.java index b3e2d5de2f..aff9c495d3 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchClient.java @@ -72,6 +72,8 @@ import co.elastic.clients.elasticsearch.core.IndexResponse; import co.elastic.clients.elasticsearch.core.InfoRequest; import co.elastic.clients.elasticsearch.core.InfoResponse; +import co.elastic.clients.elasticsearch.core.KnnEvalRequest; +import co.elastic.clients.elasticsearch.core.KnnEvalResponse; import co.elastic.clients.elasticsearch.core.ListReindexRequest; import co.elastic.clients.elasticsearch.core.ListReindexResponse; import co.elastic.clients.elasticsearch.core.MgetRequest; @@ -3578,6 +3580,83 @@ public InfoResponse info() throws IOException, ElasticsearchException { return this.transport.performRequest(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); } + // ----- Endpoint: knn_eval + + /** + * Evaluate kNN search settings. + *

+ * Estimate the recall and cost of approximate kNN search configurations on a + * dense_vector field against a more thorough baseline. The field + * must use the bbq_disk index type, and must not be inside a + * nested object. + *

+ * Each knn_settings entry reports the mean recall of the + * baseline's top k, not of relevance judgments, plus included and + * excluded query counts and cost totals. A query is excluded from the mean + * recall when the candidate finds a document scoring above the baseline's + * lowest top k score. A baseline returning fewer than + * k hits fails that query, because recall at k is + * undefined. All configurations run against one point in time. + *

+ * The default baseline uses a visit_percentage of 20 and a + * rescore_vector.oversample of 100. An exact full-precision + * baseline must be requested explicitly with allow_exact_baseline, + * and is limited to 100 million vector-by-query comparisons. + *

+ * The request is refused when the search.knn_eval.enabled cluster + * setting or the index.knn_eval.enabled index setting is + * false. + * + * @see Documentation + * on elastic.co + */ + + public KnnEvalResponse knnEval(KnnEvalRequest request) throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) KnnEvalRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Evaluate kNN search settings. + *

+ * Estimate the recall and cost of approximate kNN search configurations on a + * dense_vector field against a more thorough baseline. The field + * must use the bbq_disk index type, and must not be inside a + * nested object. + *

+ * Each knn_settings entry reports the mean recall of the + * baseline's top k, not of relevance judgments, plus included and + * excluded query counts and cost totals. A query is excluded from the mean + * recall when the candidate finds a document scoring above the baseline's + * lowest top k score. A baseline returning fewer than + * k hits fails that query, because recall at k is + * undefined. All configurations run against one point in time. + *

+ * The default baseline uses a visit_percentage of 20 and a + * rescore_vector.oversample of 100. An exact full-precision + * baseline must be requested explicitly with allow_exact_baseline, + * and is limited to 100 million vector-by-query comparisons. + *

+ * The request is refused when the search.knn_eval.enabled cluster + * setting or the index.knn_eval.enabled index setting is + * false. + * + * @param fn + * a function that initializes a builder to create the + * {@link KnnEvalRequest} + * @see Documentation + * on elastic.co + */ + + public final KnnEvalResponse knnEval(Function> fn) + throws IOException, ElasticsearchException { + return knnEval(fn.apply(new KnnEvalRequest.Builder()).build()); + } + // ----- Endpoint: list_reindex /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/BulkByPaginatedSearchFailure.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/BulkByPaginatedSearchFailure.java new file mode 100644 index 0000000000..741d7a163c --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/BulkByPaginatedSearchFailure.java @@ -0,0 +1,191 @@ +/* + * 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._types; + +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.JsonpUtils; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.json.UnionDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.ObjectBuilderBase; +import co.elastic.clients.util.TaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; +import jakarta.json.stream.JsonGenerator; +import java.lang.Object; +import java.util.Objects; +import java.util.function.Function; +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: _types.BulkByPaginatedSearchFailure + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class BulkByPaginatedSearchFailure + implements + TaggedUnion, + JsonpSerializable { + + public enum Kind { + Bulk, Search + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + private BulkByPaginatedSearchFailure(Kind kind, Object value) { + this._kind = kind; + this._value = value; + } + + private BulkByPaginatedSearchFailure(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static BulkByPaginatedSearchFailure of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code bulk}? + */ + public boolean isBulk() { + return _kind == Kind.Bulk; + } + + /** + * Get the {@code bulk} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code bulk} kind. + */ + public BulkIndexByScrollFailure bulk() { + return TaggedUnionUtils.get(this, Kind.Bulk); + } + + /** + * Is this variant instance of kind {@code search}? + */ + public boolean isSearch() { + return _kind == Kind.Search; + } + + /** + * Get the {@code search} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code search} kind. + */ + public ShardFailure search() { + return TaggedUnionUtils.get(this, Kind.Search); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder bulk(BulkIndexByScrollFailure v) { + this._kind = Kind.Bulk; + this._value = v; + return this; + } + + public ObjectBuilder bulk( + Function> fn) { + return this.bulk(fn.apply(new BulkIndexByScrollFailure.Builder()).build()); + } + + public ObjectBuilder search(ShardFailure v) { + this._kind = Kind.Search; + this._value = v; + return this; + } + + public ObjectBuilder search( + Function> fn) { + return this.search(fn.apply(new ShardFailure.Builder()).build()); + } + + public BulkByPaginatedSearchFailure build() { + _checkSingleUse(); + return new BulkByPaginatedSearchFailure(this); + } + + } + + private static JsonpDeserializer buildBulkByPaginatedSearchFailureDeserializer() { + return new UnionDeserializer.Builder( + BulkByPaginatedSearchFailure::new, false).addMember(Kind.Bulk, BulkIndexByScrollFailure._DESERIALIZER) + .addMember(Kind.Search, ShardFailure._DESERIALIZER).build(); + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer + .lazy(BulkByPaginatedSearchFailure::buildBulkByPaginatedSearchFailureDeserializer); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/BulkByPaginatedSearchFailureBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/BulkByPaginatedSearchFailureBuilders.java new file mode 100644 index 0000000000..4d16723455 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/BulkByPaginatedSearchFailureBuilders.java @@ -0,0 +1,63 @@ +/* + * 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._types; + +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link BulkByPaginatedSearchFailure} variants. + */ +public class BulkByPaginatedSearchFailureBuilders { + private BulkByPaginatedSearchFailureBuilders() { + } + + /** + * Creates a builder for the {@link BulkIndexByScrollFailure bulk} + * {@code BulkByPaginatedSearchFailure} variant. + */ + public static BulkIndexByScrollFailure.Builder bulk() { + return new BulkIndexByScrollFailure.Builder(); + } + + /** + * Creates a builder for the {@link ShardFailure search} + * {@code BulkByPaginatedSearchFailure} variant. + */ + public static ShardFailure.Builder search() { + return new ShardFailure.Builder(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InferenceString.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InferenceString.java index f0fa0acb7b..a9001dc713 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InferenceString.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InferenceString.java @@ -103,8 +103,8 @@ public final EmbeddingContentFormat format() { } /** - * Required - String which may be raw text, or the string representation of some - * other data such as an image in base64. + * Required - String which may be raw text, the string representation of some + * other data such as an image in base64, or a URL that points to the data. *

* API name: {@code value} */ @@ -183,8 +183,8 @@ public final Builder format(@Nullable EmbeddingContentFormat value) { } /** - * Required - String which may be raw text, or the string representation of some - * other data such as an image in base64. + * Required - String which may be raw text, the string representation of some + * other data such as an image in base64, or a URL that points to the data. *

* API name: {@code value} */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/PluginStats.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/PluginStats.java index 27f5e1d058..63c0de272c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/PluginStats.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/PluginStats.java @@ -79,6 +79,8 @@ public class PluginStats implements JsonpSerializable { private final boolean licensed; + private final List nativeControllerEnabledSettings; + // --------------------------------------------------------------------------------------------- private PluginStats(Builder builder) { @@ -94,6 +96,8 @@ private PluginStats(Builder builder) { this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version"); this.licensed = ApiTypeHelper.requireNonNull(builder.licensed, this, "licensed", false); + this.nativeControllerEnabledSettings = ApiTypeHelper + .unmodifiableRequired(builder.nativeControllerEnabledSettings, this, "nativeControllerEnabledSettings"); } @@ -164,6 +168,13 @@ public final boolean licensed() { return this.licensed; } + /** + * Required - API name: {@code native_controller_enabled_settings} + */ + public final List nativeControllerEnabledSettings() { + return this.nativeControllerEnabledSettings; + } + /** * Serialize this object to JSON. */ @@ -209,6 +220,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("licensed"); generator.write(this.licensed); + if (ApiTypeHelper.isDefined(this.nativeControllerEnabledSettings)) { + generator.writeKey("native_controller_enabled_settings"); + generator.writeStartArray(); + for (String item0 : this.nativeControllerEnabledSettings) { + generator.write(item0); + + } + generator.writeEnd(); + + } + } @Override @@ -241,6 +263,8 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Boolean licensed; + private List nativeControllerEnabledSettings; + public Builder() { } private Builder(PluginStats instance) { @@ -253,6 +277,7 @@ private Builder(PluginStats instance) { this.name = instance.name; this.version = instance.version; this.licensed = instance.licensed; + this.nativeControllerEnabledSettings = instance.nativeControllerEnabledSettings; } /** @@ -339,6 +364,27 @@ public final Builder licensed(boolean value) { return this; } + /** + * Required - API name: {@code native_controller_enabled_settings} + *

+ * Adds all elements of list to + * nativeControllerEnabledSettings. + */ + public final Builder nativeControllerEnabledSettings(List list) { + this.nativeControllerEnabledSettings = _listAddAll(this.nativeControllerEnabledSettings, list); + return this; + } + + /** + * Required - API name: {@code native_controller_enabled_settings} + *

+ * Adds one or more values to nativeControllerEnabledSettings. + */ + public final Builder nativeControllerEnabledSettings(String value, String... values) { + this.nativeControllerEnabledSettings = _listAdd(this.nativeControllerEnabledSettings, value, values); + return this; + } + @Override protected Builder self() { return this; @@ -383,6 +429,9 @@ protected static void setupPluginStatsDeserializer(ObjectDeserializer failures; + private final List failures; @Nullable private final Long noops; @@ -166,7 +166,7 @@ public final Long deleted() { *

* API name: {@code failures} */ - public final List failures() { + public final List failures() { return this.failures; } @@ -301,7 +301,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.failures)) { generator.writeKey("failures"); generator.writeStartArray(); - for (BulkIndexByScrollFailure item0 : this.failures) { + for (BulkByPaginatedSearchFailure item0 : this.failures) { item0.serialize(generator, mapper); } @@ -383,7 +383,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Long deleted; @Nullable - private List failures; + private List failures; @Nullable private Long noops; @@ -472,7 +472,7 @@ public final Builder deleted(@Nullable Long value) { *

* Adds all elements of list to failures. */ - public final Builder failures(List list) { + public final Builder failures(List list) { this.failures = _listAddAll(this.failures, list); return this; } @@ -485,7 +485,7 @@ public final Builder failures(List list) { *

* Adds one or more values to failures. */ - public final Builder failures(BulkIndexByScrollFailure value, BulkIndexByScrollFailure... values) { + public final Builder failures(BulkByPaginatedSearchFailure value, BulkByPaginatedSearchFailure... values) { this.failures = _listAdd(this.failures, value, values); return this; } @@ -499,8 +499,8 @@ public final Builder failures(BulkIndexByScrollFailure value, BulkIndexByScrollF * Adds a value to failures using a builder lambda. */ public final Builder failures( - Function> fn) { - return failures(fn.apply(new BulkIndexByScrollFailure.Builder()).build()); + Function> fn) { + return failures(fn.apply(new BulkByPaginatedSearchFailure.Builder()).build()); } /** @@ -651,7 +651,7 @@ protected static void setupReindexTaskResultDeserializer(ObjectDeserializerAPI + * specification + */ +@JsonpDeserializable +public enum ThreadSortOrder implements JsonEnum { + /** + * Sort by the time the thread was runnable, then by CPU time. + */ + Total("total"), + + /** + * Sort by CPU time only. + */ + Cpu("cpu"), + + ; + + private final String jsonValue; + + ThreadSortOrder(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + ThreadSortOrder.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TopMetricsAggregation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TopMetricsAggregation.java index 36312e9be5..d22e05402e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TopMetricsAggregation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TopMetricsAggregation.java @@ -23,6 +23,8 @@ 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.JsonpUtils; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; import co.elastic.clients.util.ApiTypeHelper; @@ -58,7 +60,7 @@ * specification */ @JsonpDeserializable -public class TopMetricsAggregation extends MetricAggregationBase implements AggregationVariant { +public class TopMetricsAggregation extends AggregationBase implements AggregationVariant, JsonpSerializable { private final List metrics; @Nullable @@ -69,7 +71,6 @@ public class TopMetricsAggregation extends MetricAggregationBase implements Aggr // --------------------------------------------------------------------------------------------- private TopMetricsAggregation(Builder builder) { - super(builder); this.metrics = ApiTypeHelper.unmodifiable(builder.metrics); this.size = builder.size; @@ -117,9 +118,17 @@ public final List sort() { return this.sort; } + /** + * 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) { - super.serializeInternal(generator, mapper); if (ApiTypeHelper.isDefined(this.metrics)) { generator.writeKey("metrics"); generator.writeStartArray(); @@ -148,13 +157,18 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } + @Override + public String toString() { + return JsonpUtils.toString(this); + } + // --------------------------------------------------------------------------------------------- /** * Builder for {@link TopMetricsAggregation}. */ - public static class Builder extends MetricAggregationBase.AbstractBuilder + public static class Builder extends AggregationBase.AbstractBuilder implements ObjectBuilder { @Nullable @@ -287,7 +301,7 @@ public Builder rebuild() { .lazy(Builder::new, TopMetricsAggregation::setupTopMetricsAggregationDeserializer); protected static void setupTopMetricsAggregationDeserializer(ObjectDeserializer op) { - MetricAggregationBase.setupMetricAggregationBaseDeserializer(op); + op.add(Builder::metrics, JsonpDeserializer.arrayDeserializer(TopMetricsValue._DESERIALIZER), "metrics"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TopMetricsValue.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TopMetricsValue.java index 29f6ddcf37..feb99a876e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TopMetricsValue.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TopMetricsValue.java @@ -19,6 +19,7 @@ package co.elastic.clients.elasticsearch._types.aggregations; +import co.elastic.clients.elasticsearch._types.FieldValue; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -62,11 +63,15 @@ public class TopMetricsValue implements JsonpSerializable { private final String field; + @Nullable + private final FieldValue missing; + // --------------------------------------------------------------------------------------------- private TopMetricsValue(Builder builder) { this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); + this.missing = builder.missing; } @@ -83,6 +88,18 @@ public final String field() { return this.field; } + /** + * The value to treat a document as having when it has no value for the field. + * By default, a document that is missing any of the metrics or the sort value + * is ignored. + *

+ * API name: {@code missing} + */ + @Nullable + public final FieldValue missing() { + return this.missing; + } + /** * Serialize this object to JSON. */ @@ -97,6 +114,12 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("field"); generator.write(this.field); + if (this.missing != null) { + generator.writeKey("missing"); + this.missing.serialize(generator, mapper); + + } + } @Override @@ -113,10 +136,14 @@ public String toString() { public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { private String field; + @Nullable + private FieldValue missing; + public Builder() { } private Builder(TopMetricsValue instance) { this.field = instance.field; + this.missing = instance.missing; } /** @@ -129,6 +156,77 @@ public final Builder field(String value) { return this; } + /** + * The value to treat a document as having when it has no value for the field. + * By default, a document that is missing any of the metrics or the sort value + * is ignored. + *

+ * API name: {@code missing} + */ + public final Builder missing(@Nullable FieldValue value) { + this.missing = value; + return this; + } + + /** + * The value to treat a document as having when it has no value for the field. + * By default, a document that is missing any of the metrics or the sort value + * is ignored. + *

+ * API name: {@code missing} + */ + public final Builder missing(Function> fn) { + return this.missing(fn.apply(new FieldValue.Builder()).build()); + } + + /** + * The value to treat a document as having when it has no value for the field. + * By default, a document that is missing any of the metrics or the sort value + * is ignored. + *

+ * API name: {@code missing} + */ + public final Builder missing(String value) { + this.missing = FieldValue.of(value); + return this; + } + + /** + * The value to treat a document as having when it has no value for the field. + * By default, a document that is missing any of the metrics or the sort value + * is ignored. + *

+ * API name: {@code missing} + */ + public final Builder missing(long value) { + this.missing = FieldValue.of(value); + return this; + } + + /** + * The value to treat a document as having when it has no value for the field. + * By default, a document that is missing any of the metrics or the sort value + * is ignored. + *

+ * API name: {@code missing} + */ + public final Builder missing(double value) { + this.missing = FieldValue.of(value); + return this; + } + + /** + * The value to treat a document as having when it has no value for the field. + * By default, a document that is missing any of the metrics or the sort value + * is ignored. + *

+ * API name: {@code missing} + */ + public final Builder missing(boolean value) { + this.missing = FieldValue.of(value); + return this; + } + @Override protected Builder self() { return this; @@ -164,6 +262,7 @@ public Builder rebuild() { protected static void setupTopMetricsValueDeserializer(ObjectDeserializer op) { op.add(Builder::field, JsonpDeserializer.stringDeserializer(), "field"); + op.add(Builder::missing, FieldValue._DESERIALIZER, "missing"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/DynamicProperty.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/DynamicProperty.java index 9c3fcac8e7..ea1940fe2c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/DynamicProperty.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/DynamicProperty.java @@ -21,6 +21,7 @@ import co.elastic.clients.elasticsearch._types.FieldValue; import co.elastic.clients.elasticsearch._types.Script; +import co.elastic.clients.elasticsearch.indices.FielddataFrequencyFilter; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -85,12 +86,21 @@ public class DynamicProperty extends DocValuesPropertyBase implements PropertyVa @Nullable private final TimeSeriesMetricType timeSeriesMetric; + @Nullable + private final Boolean timeSeriesDimension; + @Nullable private final String analyzer; @Nullable private final Boolean eagerGlobalOrdinals; + @Nullable + private final Boolean fielddata; + + @Nullable + private final FielddataFrequencyFilter fielddataFrequencyFilter; + @Nullable private final Boolean index; @@ -115,6 +125,9 @@ public class DynamicProperty extends DocValuesPropertyBase implements PropertyVa @Nullable private final String searchQuoteAnalyzer; + @Nullable + private final String similarity; + @Nullable private final TermVectorOption termVector; @@ -127,6 +140,9 @@ public class DynamicProperty extends DocValuesPropertyBase implements PropertyVa @Nullable private final String locale; + @Nullable + private final Subobjects subobjects; + // --------------------------------------------------------------------------------------------- private DynamicProperty(Builder builder) { @@ -140,8 +156,11 @@ private DynamicProperty(Builder builder) { this.onScriptError = builder.onScriptError; this.ignoreMalformed = builder.ignoreMalformed; this.timeSeriesMetric = builder.timeSeriesMetric; + this.timeSeriesDimension = builder.timeSeriesDimension; this.analyzer = builder.analyzer; this.eagerGlobalOrdinals = builder.eagerGlobalOrdinals; + this.fielddata = builder.fielddata; + this.fielddataFrequencyFilter = builder.fielddataFrequencyFilter; this.index = builder.index; this.indexOptions = builder.indexOptions; this.indexPhrases = builder.indexPhrases; @@ -150,10 +169,12 @@ private DynamicProperty(Builder builder) { this.positionIncrementGap = builder.positionIncrementGap; this.searchAnalyzer = builder.searchAnalyzer; this.searchQuoteAnalyzer = builder.searchQuoteAnalyzer; + this.similarity = builder.similarity; this.termVector = builder.termVector; this.format = builder.format; this.precisionStep = builder.precisionStep; this.locale = builder.locale; + this.subobjects = builder.subobjects; } @@ -233,6 +254,14 @@ public final TimeSeriesMetricType timeSeriesMetric() { return this.timeSeriesMetric; } + /** + * API name: {@code time_series_dimension} + */ + @Nullable + public final Boolean timeSeriesDimension() { + return this.timeSeriesDimension; + } + /** * API name: {@code analyzer} */ @@ -249,6 +278,22 @@ public final Boolean eagerGlobalOrdinals() { return this.eagerGlobalOrdinals; } + /** + * API name: {@code fielddata} + */ + @Nullable + public final Boolean fielddata() { + return this.fielddata; + } + + /** + * API name: {@code fielddata_frequency_filter} + */ + @Nullable + public final FielddataFrequencyFilter fielddataFrequencyFilter() { + return this.fielddataFrequencyFilter; + } + /** * API name: {@code index} */ @@ -313,6 +358,14 @@ public final String searchQuoteAnalyzer() { return this.searchQuoteAnalyzer; } + /** + * API name: {@code similarity} + */ + @Nullable + public final String similarity() { + return this.similarity; + } + /** * API name: {@code term_vector} */ @@ -345,6 +398,14 @@ public final String locale() { return this.locale; } + /** + * API name: {@code subobjects} + */ + @Nullable + public final Subobjects subobjects() { + return this.subobjects; + } + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "{dynamic_type}"); @@ -387,6 +448,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("time_series_metric"); this.timeSeriesMetric.serialize(generator, mapper); } + if (this.timeSeriesDimension != null) { + generator.writeKey("time_series_dimension"); + generator.write(this.timeSeriesDimension); + + } if (this.analyzer != null) { generator.writeKey("analyzer"); generator.write(this.analyzer); @@ -396,6 +462,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("eager_global_ordinals"); generator.write(this.eagerGlobalOrdinals); + } + if (this.fielddata != null) { + generator.writeKey("fielddata"); + generator.write(this.fielddata); + + } + if (this.fielddataFrequencyFilter != null) { + generator.writeKey("fielddata_frequency_filter"); + this.fielddataFrequencyFilter.serialize(generator, mapper); + } if (this.index != null) { generator.writeKey("index"); @@ -435,6 +511,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("search_quote_analyzer"); generator.write(this.searchQuoteAnalyzer); + } + if (this.similarity != null) { + generator.writeKey("similarity"); + generator.write(this.similarity); + } if (this.termVector != null) { generator.writeKey("term_vector"); @@ -455,6 +536,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.locale); } + if (this.subobjects != null) { + generator.writeKey("subobjects"); + this.subobjects.serialize(generator, mapper); + } } @@ -491,12 +576,21 @@ public static class Builder extends DocValuesPropertyBase.AbstractBuilder> fn) { + return this.fielddataFrequencyFilter(fn.apply(new FielddataFrequencyFilter.Builder()).build()); + } + /** * API name: {@code index} */ @@ -757,6 +894,14 @@ public final Builder searchQuoteAnalyzer(@Nullable String value) { return this; } + /** + * API name: {@code similarity} + */ + public final Builder similarity(@Nullable String value) { + this.similarity = value; + return this; + } + /** * API name: {@code term_vector} */ @@ -789,6 +934,14 @@ public final Builder locale(@Nullable String value) { return this; } + /** + * API name: {@code subobjects} + */ + public final Builder subobjects(@Nullable Subobjects value) { + this.subobjects = value; + return this; + } + @Override protected Builder self() { return this; @@ -831,8 +984,11 @@ protected static void setupDynamicPropertyDeserializer(ObjectDeserializer filter; @@ -112,6 +115,14 @@ public Query.Kind _queryKind() { return Query.Kind.Bool; } + /** + * ServiceAccountQuery variant kind. + */ + @Override + public ServiceAccountQuery.Kind _serviceAccountQueryKind() { + return ServiceAccountQuery.Kind.Bool; + } + /** * RoleQuery variant kind. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/DenseVectorQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/DenseVectorQuery.java new file mode 100644 index 0000000000..c34182bb71 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/DenseVectorQuery.java @@ -0,0 +1,375 @@ +/* + * 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._types.query_dsl; + +import co.elastic.clients.elasticsearch._types.QueryVectorBuilder; +import co.elastic.clients.elasticsearch._types.QueryVectorBuilderVariant; +import co.elastic.clients.elasticsearch._types.mapping.DenseVectorSimilarity; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +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 jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.Float; +import java.lang.String; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: _types.query_dsl.DenseVectorQuery + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DenseVectorQuery extends QueryBase implements QueryVariant { + private final String field; + + private final List queryVector; + + @Nullable + private final QueryVectorBuilder queryVectorBuilder; + + @Nullable + private final DenseVectorSimilarity similarityFunction; + + @Nullable + private final Boolean quantized; + + // --------------------------------------------------------------------------------------------- + + private DenseVectorQuery(Builder builder) { + super(builder); + + this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); + this.queryVector = ApiTypeHelper.unmodifiable(builder.queryVector); + this.queryVectorBuilder = builder.queryVectorBuilder; + this.similarityFunction = builder.similarityFunction; + this.quantized = builder.quantized; + + } + + public static DenseVectorQuery of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Query variant kind. + */ + @Override + public Query.Kind _queryKind() { + return Query.Kind.DenseVector; + } + + /** + * Required - The name of the dense_vector field to search against. + * The field can be indexed, or not indexed (index: false). + *

+ * API name: {@code field} + */ + public final String field() { + return this.field; + } + + /** + * The query vector. It must have the same number of dimensions as the field. + * You must provide either query_vector or + * query_vector_builder, but not both. + *

+ * API name: {@code query_vector} + */ + public final List queryVector() { + return this.queryVector; + } + + /** + * The configuration to build the query vector, for example by running a text + * embedding model. You must provide either query_vector or + * query_vector_builder, but not both. + *

+ * API name: {@code query_vector_builder} + */ + @Nullable + public final QueryVectorBuilder queryVectorBuilder() { + return this.queryVectorBuilder; + } + + /** + * The similarity used for scoring, which overrides the similarity of the field + * for this query. It defaults to the similarity of the field, or to + * cosine for a field that is not indexed. For bit + * fields, only l2_norm is supported. It can't be combined with + * quantized: true. + *

+ * API name: {@code similarity_function} + */ + @Nullable + public final DenseVectorSimilarity similarityFunction() { + return this.similarityFunction; + } + + /** + * If false, the documents are scored with the full-precision + * vectors, regardless of the index options of the field. If true, + * the documents are scored with the quantized vectors of a quantized field, + * which is faster but less accurate. For a field that is not quantized, + * true has no effect. + *

+ * API name: {@code quantized} + */ + @Nullable + public final Boolean quantized() { + return this.quantized; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + generator.writeKey("field"); + generator.write(this.field); + + if (ApiTypeHelper.isDefined(this.queryVector)) { + generator.writeKey("query_vector"); + generator.writeStartArray(); + for (Float item0 : this.queryVector) { + generator.write(item0); + + } + generator.writeEnd(); + + } + if (this.queryVectorBuilder != null) { + generator.writeKey("query_vector_builder"); + this.queryVectorBuilder.serialize(generator, mapper); + + } + if (this.similarityFunction != null) { + generator.writeKey("similarity_function"); + this.similarityFunction.serialize(generator, mapper); + } + if (this.quantized != null) { + generator.writeKey("quantized"); + generator.write(this.quantized); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DenseVectorQuery}. + */ + + public static class Builder extends QueryBase.AbstractBuilder implements ObjectBuilder { + private String field; + + @Nullable + private List queryVector; + + @Nullable + private QueryVectorBuilder queryVectorBuilder; + + @Nullable + private DenseVectorSimilarity similarityFunction; + + @Nullable + private Boolean quantized; + + public Builder() { + } + private Builder(DenseVectorQuery instance) { + this.field = instance.field; + this.queryVector = instance.queryVector; + this.queryVectorBuilder = instance.queryVectorBuilder; + this.similarityFunction = instance.similarityFunction; + this.quantized = instance.quantized; + + } + /** + * Required - The name of the dense_vector field to search against. + * The field can be indexed, or not indexed (index: false). + *

+ * API name: {@code field} + */ + public final Builder field(String value) { + this.field = value; + return this; + } + + /** + * The query vector. It must have the same number of dimensions as the field. + * You must provide either query_vector or + * query_vector_builder, but not both. + *

+ * API name: {@code query_vector} + *

+ * Adds all elements of list to queryVector. + */ + public final Builder queryVector(List list) { + this.queryVector = _listAddAll(this.queryVector, list); + return this; + } + + /** + * The query vector. It must have the same number of dimensions as the field. + * You must provide either query_vector or + * query_vector_builder, but not both. + *

+ * API name: {@code query_vector} + *

+ * Adds one or more values to queryVector. + */ + public final Builder queryVector(Float value, Float... values) { + this.queryVector = _listAdd(this.queryVector, value, values); + return this; + } + + /** + * The configuration to build the query vector, for example by running a text + * embedding model. You must provide either query_vector or + * query_vector_builder, but not both. + *

+ * API name: {@code query_vector_builder} + */ + public final Builder queryVectorBuilder(@Nullable QueryVectorBuilder value) { + this.queryVectorBuilder = value; + return this; + } + + /** + * The configuration to build the query vector, for example by running a text + * embedding model. You must provide either query_vector or + * query_vector_builder, but not both. + *

+ * API name: {@code query_vector_builder} + */ + public final Builder queryVectorBuilder( + Function> fn) { + return this.queryVectorBuilder(fn.apply(new QueryVectorBuilder.Builder()).build()); + } + + /** + * The configuration to build the query vector, for example by running a text + * embedding model. You must provide either query_vector or + * query_vector_builder, but not both. + *

+ * API name: {@code query_vector_builder} + */ + public final Builder queryVectorBuilder(QueryVectorBuilderVariant value) { + this.queryVectorBuilder = value._toQueryVectorBuilder(); + return this; + } + + /** + * The similarity used for scoring, which overrides the similarity of the field + * for this query. It defaults to the similarity of the field, or to + * cosine for a field that is not indexed. For bit + * fields, only l2_norm is supported. It can't be combined with + * quantized: true. + *

+ * API name: {@code similarity_function} + */ + public final Builder similarityFunction(@Nullable DenseVectorSimilarity value) { + this.similarityFunction = value; + return this; + } + + /** + * If false, the documents are scored with the full-precision + * vectors, regardless of the index options of the field. If true, + * the documents are scored with the quantized vectors of a quantized field, + * which is faster but less accurate. For a field that is not quantized, + * true has no effect. + *

+ * API name: {@code quantized} + */ + public final Builder quantized(@Nullable Boolean value) { + this.quantized = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DenseVectorQuery}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DenseVectorQuery build() { + _checkSingleUse(); + + return new DenseVectorQuery(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DenseVectorQuery} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + DenseVectorQuery::setupDenseVectorQueryDeserializer); + + protected static void setupDenseVectorQueryDeserializer(ObjectDeserializer op) { + QueryBase.setupQueryBaseDeserializer(op); + op.add(Builder::field, JsonpDeserializer.stringDeserializer(), "field"); + op.add(Builder::queryVector, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.floatDeserializer()), + "query_vector"); + op.add(Builder::queryVectorBuilder, QueryVectorBuilder._DESERIALIZER, "query_vector_builder"); + op.add(Builder::similarityFunction, DenseVectorSimilarity._DESERIALIZER, "similarity_function"); + op.add(Builder::quantized, JsonpDeserializer.booleanDeserializer(), "quantized"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/ExistsQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/ExistsQuery.java index 40063d26f7..bda2578762 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/ExistsQuery.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/ExistsQuery.java @@ -23,6 +23,8 @@ import co.elastic.clients.elasticsearch.security.query_api_keys.ApiKeyQueryVariant; import co.elastic.clients.elasticsearch.security.query_role.RoleQuery; import co.elastic.clients.elasticsearch.security.query_role.RoleQueryVariant; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQuery; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQueryVariant; import co.elastic.clients.elasticsearch.security.query_user.UserQuery; import co.elastic.clients.elasticsearch.security.query_user.UserQueryVariant; import co.elastic.clients.json.JsonpDeserializable; @@ -65,6 +67,7 @@ public class ExistsQuery extends QueryBase implements ApiKeyQueryVariant, QueryVariant, + ServiceAccountQueryVariant, RoleQueryVariant, UserQueryVariant { private final String field; @@ -98,6 +101,14 @@ public Query.Kind _queryKind() { return Query.Kind.Exists; } + /** + * ServiceAccountQuery variant kind. + */ + @Override + public ServiceAccountQuery.Kind _serviceAccountQueryKind() { + return ServiceAccountQuery.Kind.Exists; + } + /** * RoleQuery variant kind. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/IdsQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/IdsQuery.java index 0fc9bba037..ac03ed461a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/IdsQuery.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/IdsQuery.java @@ -23,6 +23,8 @@ import co.elastic.clients.elasticsearch.security.query_api_keys.ApiKeyQueryVariant; import co.elastic.clients.elasticsearch.security.query_role.RoleQuery; import co.elastic.clients.elasticsearch.security.query_role.RoleQueryVariant; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQuery; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQueryVariant; import co.elastic.clients.elasticsearch.security.query_user.UserQuery; import co.elastic.clients.elasticsearch.security.query_user.UserQueryVariant; import co.elastic.clients.json.JsonpDeserializable; @@ -66,6 +68,7 @@ public class IdsQuery extends QueryBase implements ApiKeyQueryVariant, QueryVariant, + ServiceAccountQueryVariant, RoleQueryVariant, UserQueryVariant { private final List values; @@ -99,6 +102,14 @@ public Query.Kind _queryKind() { return Query.Kind.Ids; } + /** + * ServiceAccountQuery variant kind. + */ + @Override + public ServiceAccountQuery.Kind _serviceAccountQueryKind() { + return ServiceAccountQuery.Kind.Ids; + } + /** * RoleQuery variant kind. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/MatchAllQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/MatchAllQuery.java index bebfd6fa90..694bb72a5e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/MatchAllQuery.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/MatchAllQuery.java @@ -23,6 +23,8 @@ import co.elastic.clients.elasticsearch.security.query_api_keys.ApiKeyQueryVariant; import co.elastic.clients.elasticsearch.security.query_role.RoleQuery; import co.elastic.clients.elasticsearch.security.query_role.RoleQueryVariant; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQuery; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQueryVariant; import co.elastic.clients.elasticsearch.security.query_user.UserQuery; import co.elastic.clients.elasticsearch.security.query_user.UserQueryVariant; import co.elastic.clients.json.JsonpDeserializable; @@ -62,6 +64,7 @@ public class MatchAllQuery extends QueryBase implements ApiKeyQueryVariant, QueryVariant, + ServiceAccountQueryVariant, RoleQueryVariant, UserQueryVariant { // --------------------------------------------------------------------------------------------- @@ -91,6 +94,14 @@ public Query.Kind _queryKind() { return Query.Kind.MatchAll; } + /** + * ServiceAccountQuery variant kind. + */ + @Override + public ServiceAccountQuery.Kind _serviceAccountQueryKind() { + return ServiceAccountQuery.Kind.MatchAll; + } + /** * RoleQuery variant kind. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/Query.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/Query.java index db135901f8..45c09626ce 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/Query.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/Query.java @@ -89,6 +89,8 @@ public enum Kind implements JsonEnum { ConstantScore("constant_score"), + DenseVector("dense_vector"), + DisMax("dis_max"), DistanceFeature("distance_feature"), @@ -347,6 +349,23 @@ public ConstantScoreQuery constantScore() { return TaggedUnionUtils.get(this, Kind.ConstantScore); } + /** + * Is this variant instance of kind {@code dense_vector}? + */ + public boolean isDenseVector() { + return _kind == Kind.DenseVector; + } + + /** + * Get the {@code dense_vector} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code dense_vector} kind. + */ + public DenseVectorQuery denseVector() { + return TaggedUnionUtils.get(this, Kind.DenseVector); + } + /** * Is this variant instance of kind {@code dis_max}? */ @@ -1434,6 +1453,17 @@ public ObjectBuilder constantScore( return this.constantScore(fn.apply(new ConstantScoreQuery.Builder()).build()); } + public ObjectBuilder denseVector(DenseVectorQuery v) { + this._kind = Kind.DenseVector; + this._value = v; + return this; + } + + public ObjectBuilder denseVector( + Function> fn) { + return this.denseVector(fn.apply(new DenseVectorQuery.Builder()).build()); + } + public ObjectBuilder disMax(DisMaxQuery v) { this._kind = Kind.DisMax; this._value = v; @@ -2052,6 +2082,7 @@ protected static void setupQueryDeserializer(ObjectDeserializer op) { op.add(Builder::common, CommonTermsQuery._DESERIALIZER, "common"); op.add(Builder::combinedFields, CombinedFieldsQuery._DESERIALIZER, "combined_fields"); op.add(Builder::constantScore, ConstantScoreQuery._DESERIALIZER, "constant_score"); + op.add(Builder::denseVector, DenseVectorQuery._DESERIALIZER, "dense_vector"); op.add(Builder::disMax, DisMaxQuery._DESERIALIZER, "dis_max"); op.add(Builder::distanceFeature, DistanceFeatureQuery._DESERIALIZER, "distance_feature"); op.add(Builder::exists, ExistsQuery._DESERIALIZER, "exists"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/QueryBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/QueryBuilders.java index 7c4da70ca2..bdd6e35143 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/QueryBuilders.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/QueryBuilders.java @@ -131,6 +131,24 @@ public static Query constantScore(Function> fn) { + Query.Builder builder = new Query.Builder(); + builder.denseVector(fn.apply(new DenseVectorQuery.Builder()).build()); + return builder.build(); + } + /** * Creates a builder for the {@link DisMaxQuery dis_max} {@code Query} variant. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/RangeQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/RangeQuery.java index 6255c59e40..fb28f04a5c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/RangeQuery.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/RangeQuery.java @@ -23,6 +23,8 @@ import co.elastic.clients.elasticsearch.security.query_api_keys.ApiKeyQueryVariant; import co.elastic.clients.elasticsearch.security.query_role.RoleQuery; import co.elastic.clients.elasticsearch.security.query_role.RoleQueryVariant; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQuery; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQueryVariant; import co.elastic.clients.elasticsearch.security.query_user.UserQuery; import co.elastic.clients.elasticsearch.security.query_user.UserQueryVariant; import co.elastic.clients.json.JsonEnum; @@ -71,6 +73,7 @@ public class RangeQuery TaggedUnion, ApiKeyQueryVariant, QueryVariant, + ServiceAccountQueryVariant, RoleQueryVariant, UserQueryVariant, JsonpSerializable { @@ -123,6 +126,14 @@ public Query.Kind _queryKind() { return Query.Kind.Range; } + /** + * ServiceAccountQuery variant kind. + */ + @Override + public ServiceAccountQuery.Kind _serviceAccountQueryKind() { + return ServiceAccountQuery.Kind.Range; + } + /** * RoleQuery variant kind. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/SimpleQueryStringQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/SimpleQueryStringQuery.java index 5588c0bd77..322fb1a55e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/SimpleQueryStringQuery.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/SimpleQueryStringQuery.java @@ -23,6 +23,8 @@ import co.elastic.clients.elasticsearch.security.query_api_keys.ApiKeyQueryVariant; import co.elastic.clients.elasticsearch.security.query_role.RoleQuery; import co.elastic.clients.elasticsearch.security.query_role.RoleQueryVariant; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQuery; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQueryVariant; import co.elastic.clients.elasticsearch.security.query_user.UserQuery; import co.elastic.clients.elasticsearch.security.query_user.UserQueryVariant; import co.elastic.clients.json.JsonEnums; @@ -70,6 +72,7 @@ public class SimpleQueryStringQuery extends QueryBase implements ApiKeyQueryVariant, QueryVariant, + ServiceAccountQueryVariant, RoleQueryVariant, UserQueryVariant { @Nullable @@ -149,6 +152,14 @@ public Query.Kind _queryKind() { return Query.Kind.SimpleQueryString; } + /** + * ServiceAccountQuery variant kind. + */ + @Override + public ServiceAccountQuery.Kind _serviceAccountQueryKind() { + return ServiceAccountQuery.Kind.SimpleQueryString; + } + /** * RoleQuery variant kind. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/TermsQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/TermsQuery.java index 6259c1d3f4..d2ca4f4c34 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/TermsQuery.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/TermsQuery.java @@ -23,6 +23,8 @@ import co.elastic.clients.elasticsearch.security.query_api_keys.ApiKeyQueryVariant; import co.elastic.clients.elasticsearch.security.query_role.RoleQuery; import co.elastic.clients.elasticsearch.security.query_role.RoleQueryVariant; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQuery; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQueryVariant; import co.elastic.clients.elasticsearch.security.query_user.UserQuery; import co.elastic.clients.elasticsearch.security.query_user.UserQueryVariant; import co.elastic.clients.json.JsonpDeserializable; @@ -65,6 +67,7 @@ public class TermsQuery extends QueryBase implements ApiKeyQueryVariant, QueryVariant, + ServiceAccountQueryVariant, RoleQueryVariant, UserQueryVariant { private final String field; @@ -100,6 +103,14 @@ public Query.Kind _queryKind() { return Query.Kind.Terms; } + /** + * ServiceAccountQuery variant kind. + */ + @Override + public ServiceAccountQuery.Kind _serviceAccountQueryKind() { + return ServiceAccountQuery.Kind.Terms; + } + /** * RoleQuery variant kind. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/AliasesRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/AliasesRequest.java index f56aad44b4..62dbd7ef4c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/AliasesRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/AliasesRequest.java @@ -61,7 +61,7 @@ // typedef: cat.aliases.Request /** - * Get aliases. + * Get a compact list of aliases. *

* Get the cluster's index aliases, including filter and routing information. * This API does not return data stream aliases. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ComponentTemplatesRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ComponentTemplatesRequest.java index d9c0401b22..08ee00692a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ComponentTemplatesRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ComponentTemplatesRequest.java @@ -61,7 +61,7 @@ // typedef: cat.component_templates.Request /** - * Get component templates. + * Get a compact list of component templates. *

* Get information about component templates in a cluster. Component templates * are building blocks for constructing index templates that specify index diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatAsyncClient.java index 7bed9ad07d..c653caf9bb 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatAsyncClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatAsyncClient.java @@ -68,7 +68,7 @@ public ElasticsearchCatAsyncClient withTransportOptions(@Nullable TransportOptio // ----- Endpoint: cat.aliases /** - * Get aliases. + * Get a compact list of aliases. *

* Get the cluster's index aliases, including filter and routing information. * This API does not return data stream aliases. @@ -90,7 +90,7 @@ public CompletableFuture aliases(AliasesRequest request) { } /** - * Get aliases. + * Get a compact list of aliases. *

* Get the cluster's index aliases, including filter and routing information. * This API does not return data stream aliases. @@ -113,7 +113,7 @@ public final CompletableFuture aliases( } /** - * Get aliases. + * Get a compact list of aliases. *

* Get the cluster's index aliases, including filter and routing information. * This API does not return data stream aliases. @@ -199,7 +199,7 @@ public CompletableFuture allocation() { // ----- Endpoint: cat.component_templates /** - * Get component templates. + * Get a compact list of component templates. *

* Get information about component templates in a cluster. Component templates * are building blocks for constructing index templates that specify index @@ -222,7 +222,7 @@ public CompletableFuture componentTemplates(Componen } /** - * Get component templates. + * Get a compact list of component templates. *

* Get information about component templates in a cluster. Component templates * are building blocks for constructing index templates that specify index @@ -246,7 +246,7 @@ public final CompletableFuture componentTemplates( } /** - * Get component templates. + * Get a compact list of component templates. *

* Get information about component templates in a cluster. Component templates * are building blocks for constructing index templates that specify index @@ -418,7 +418,7 @@ public CompletableFuture fielddata() { // ----- Endpoint: cat.health /** - * Get the cluster health status. + * Get a compact cluster health summary. *

* 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 @@ -445,7 +445,7 @@ public CompletableFuture health(HealthRequest request) { } /** - * Get the cluster health status. + * Get a compact cluster health summary. *

* 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 @@ -473,7 +473,7 @@ public final CompletableFuture health( } /** - * Get the cluster health status. + * Get a compact cluster health summary. *

* 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 @@ -515,7 +515,7 @@ public CompletableFuture help() { // ----- Endpoint: cat.indices /** - * Get index information. + * Get a compact list of indices. *

* Get high-level information about indices in a cluster, including backing * indices for data streams. @@ -563,7 +563,7 @@ public CompletableFuture indices(IndicesRequest request) { } /** - * Get index information. + * Get a compact list of indices. *

* Get high-level information about indices in a cluster, including backing * indices for data streams. @@ -612,7 +612,7 @@ public final CompletableFuture indices( } /** - * Get index information. + * Get a compact list of indices. *

* Get high-level information about indices in a cluster, including backing * indices for data streams. @@ -1071,7 +1071,7 @@ public CompletableFuture nodeattrs() { // ----- Endpoint: cat.nodes /** - * Get node information. + * Get a compact list of nodes. *

* Get information about the nodes in a cluster. IMPORTANT: cat APIs are only * intended for human consumption using the command line or Kibana console. They @@ -1091,7 +1091,7 @@ public CompletableFuture nodes(NodesRequest request) { } /** - * Get node information. + * Get a compact list of nodes. *

* Get information about the nodes in a cluster. IMPORTANT: cat APIs are only * intended for human consumption using the command line or Kibana console. They @@ -1112,7 +1112,7 @@ public final CompletableFuture nodes( } /** - * Get node information. + * Get a compact list of nodes. *

* Get information about the nodes in a cluster. IMPORTANT: cat APIs are only * intended for human consumption using the command line or Kibana console. They @@ -1327,7 +1327,7 @@ public CompletableFuture recovery() { // ----- Endpoint: cat.repositories /** - * Get snapshot repository information. + * Get a compact list of snapshot repositories. *

* Get a list of snapshot repositories for a cluster. IMPORTANT: cat APIs are * only intended for human consumption using the command line or Kibana console. @@ -1347,7 +1347,7 @@ public CompletableFuture repositories(RepositoriesRequest } /** - * Get snapshot repository information. + * Get a compact list of snapshot repositories. *

* Get a list of snapshot repositories for a cluster. IMPORTANT: cat APIs are * only intended for human consumption using the command line or Kibana console. @@ -1368,7 +1368,7 @@ public final CompletableFuture repositories( } /** - * Get snapshot repository information. + * Get a compact list of snapshot repositories. *

* Get a list of snapshot repositories for a cluster. IMPORTANT: cat APIs are * only intended for human consumption using the command line or Kibana console. @@ -1513,7 +1513,7 @@ public CompletableFuture shards() { // ----- Endpoint: cat.snapshots /** - * Get snapshot information. + * Get a compact list of snapshots. *

* Get information about the snapshots stored in one or more repositories. A * snapshot is a backup of an index or running Elasticsearch cluster. IMPORTANT: @@ -1534,7 +1534,7 @@ public CompletableFuture snapshots(SnapshotsRequest request) } /** - * Get snapshot information. + * Get a compact list of snapshots. *

* Get information about the snapshots stored in one or more repositories. A * snapshot is a backup of an index or running Elasticsearch cluster. IMPORTANT: @@ -1556,7 +1556,7 @@ public final CompletableFuture snapshots( } /** - * Get snapshot information. + * Get a compact list of snapshots. *

* Get information about the snapshots stored in one or more repositories. A * snapshot is a backup of an index or running Elasticsearch cluster. IMPORTANT: @@ -1577,7 +1577,7 @@ public CompletableFuture snapshots() { // ----- Endpoint: cat.tasks /** - * Get task information. + * Get a compact list of running tasks. *

* Get information about tasks currently running in the cluster. IMPORTANT: cat * APIs are only intended for human consumption using the command line or Kibana @@ -1597,7 +1597,7 @@ public CompletableFuture tasks(TasksRequest request) { } /** - * Get task information. + * Get a compact list of running tasks. *

* Get information about tasks currently running in the cluster. IMPORTANT: cat * APIs are only intended for human consumption using the command line or Kibana @@ -1618,7 +1618,7 @@ public final CompletableFuture tasks( } /** - * Get task information. + * Get a compact list of running tasks. *

* Get information about tasks currently running in the cluster. IMPORTANT: cat * APIs are only intended for human consumption using the command line or Kibana diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatClient.java index 3a2fa06cf1..7f2463c0af 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ElasticsearchCatClient.java @@ -69,7 +69,7 @@ public ElasticsearchCatClient withTransportOptions(@Nullable TransportOptions tr // ----- Endpoint: cat.aliases /** - * Get aliases. + * Get a compact list of aliases. *

* Get the cluster's index aliases, including filter and routing information. * This API does not return data stream aliases. @@ -91,7 +91,7 @@ public AliasesResponse aliases(AliasesRequest request) throws IOException, Elast } /** - * Get aliases. + * Get a compact list of aliases. *

* Get the cluster's index aliases, including filter and routing information. * This API does not return data stream aliases. @@ -114,7 +114,7 @@ public final AliasesResponse aliases(Function * Get the cluster's index aliases, including filter and routing information. * This API does not return data stream aliases. @@ -200,7 +200,7 @@ public AllocationResponse allocation() throws IOException, ElasticsearchExceptio // ----- Endpoint: cat.component_templates /** - * Get component templates. + * Get a compact list of component templates. *

* Get information about component templates in a cluster. Component templates * are building blocks for constructing index templates that specify index @@ -224,7 +224,7 @@ public ComponentTemplatesResponse componentTemplates(ComponentTemplatesRequest r } /** - * Get component templates. + * Get a compact list of component templates. *

* Get information about component templates in a cluster. Component templates * are building blocks for constructing index templates that specify index @@ -249,7 +249,7 @@ public final ComponentTemplatesResponse componentTemplates( } /** - * Get component templates. + * Get a compact list of component templates. *

* Get information about component templates in a cluster. Component templates * are building blocks for constructing index templates that specify index @@ -421,7 +421,7 @@ public FielddataResponse fielddata() throws IOException, ElasticsearchException // ----- Endpoint: cat.health /** - * Get the cluster health status. + * Get a compact cluster health summary. *

* 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 @@ -448,7 +448,7 @@ public HealthResponse health(HealthRequest request) throws IOException, Elastics } /** - * Get the cluster health status. + * Get a compact cluster health summary. *

* 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 @@ -476,7 +476,7 @@ public final HealthResponse health(Function * 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 @@ -518,7 +518,7 @@ public TextResponse help() throws IOException, ElasticsearchException { // ----- Endpoint: cat.indices /** - * Get index information. + * Get a compact list of indices. *

* Get high-level information about indices in a cluster, including backing * indices for data streams. @@ -566,7 +566,7 @@ public IndicesResponse indices(IndicesRequest request) throws IOException, Elast } /** - * Get index information. + * Get a compact list of indices. *

* Get high-level information about indices in a cluster, including backing * indices for data streams. @@ -615,7 +615,7 @@ public final IndicesResponse indices(Function * Get high-level information about indices in a cluster, including backing * indices for data streams. @@ -1079,7 +1079,7 @@ public NodeattrsResponse nodeattrs() throws IOException, ElasticsearchException // ----- Endpoint: cat.nodes /** - * Get node information. + * Get a compact list of nodes. *

* Get information about the nodes in a cluster. IMPORTANT: cat APIs are only * intended for human consumption using the command line or Kibana console. They @@ -1099,7 +1099,7 @@ public NodesResponse nodes(NodesRequest request) throws IOException, Elasticsear } /** - * Get node information. + * Get a compact list of nodes. *

* Get information about the nodes in a cluster. IMPORTANT: cat APIs are only * intended for human consumption using the command line or Kibana console. They @@ -1120,7 +1120,7 @@ public final NodesResponse nodes(Function * Get information about the nodes in a cluster. IMPORTANT: cat APIs are only * intended for human consumption using the command line or Kibana console. They @@ -1336,7 +1336,7 @@ public RecoveryResponse recovery() throws IOException, ElasticsearchException { // ----- Endpoint: cat.repositories /** - * Get snapshot repository information. + * Get a compact list of snapshot repositories. *

* Get a list of snapshot repositories for a cluster. IMPORTANT: cat APIs are * only intended for human consumption using the command line or Kibana console. @@ -1356,7 +1356,7 @@ public RepositoriesResponse repositories(RepositoriesRequest request) throws IOE } /** - * Get snapshot repository information. + * Get a compact list of snapshot repositories. *

* Get a list of snapshot repositories for a cluster. IMPORTANT: cat APIs are * only intended for human consumption using the command line or Kibana console. @@ -1378,7 +1378,7 @@ public final RepositoriesResponse repositories( } /** - * Get snapshot repository information. + * Get a compact list of snapshot repositories. *

* Get a list of snapshot repositories for a cluster. IMPORTANT: cat APIs are * only intended for human consumption using the command line or Kibana console. @@ -1523,7 +1523,7 @@ public ShardsResponse shards() throws IOException, ElasticsearchException { // ----- Endpoint: cat.snapshots /** - * Get snapshot information. + * Get a compact list of snapshots. *

* Get information about the snapshots stored in one or more repositories. A * snapshot is a backup of an index or running Elasticsearch cluster. IMPORTANT: @@ -1544,7 +1544,7 @@ public SnapshotsResponse snapshots(SnapshotsRequest request) throws IOException, } /** - * Get snapshot information. + * Get a compact list of snapshots. *

* Get information about the snapshots stored in one or more repositories. A * snapshot is a backup of an index or running Elasticsearch cluster. IMPORTANT: @@ -1566,7 +1566,7 @@ public final SnapshotsResponse snapshots(Function * Get information about the snapshots stored in one or more repositories. A * snapshot is a backup of an index or running Elasticsearch cluster. IMPORTANT: @@ -1587,7 +1587,7 @@ public SnapshotsResponse snapshots() throws IOException, ElasticsearchException // ----- Endpoint: cat.tasks /** - * Get task information. + * Get a compact list of running tasks. *

* Get information about tasks currently running in the cluster. IMPORTANT: cat * APIs are only intended for human consumption using the command line or Kibana @@ -1607,7 +1607,7 @@ public TasksResponse tasks(TasksRequest request) throws IOException, Elasticsear } /** - * Get task information. + * Get a compact list of running tasks. *

* Get information about tasks currently running in the cluster. IMPORTANT: cat * APIs are only intended for human consumption using the command line or Kibana @@ -1628,7 +1628,7 @@ public final TasksResponse tasks(Function * Get information about tasks currently running in the cluster. IMPORTANT: cat * APIs are only intended for human consumption using the command line or Kibana diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/HealthRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/HealthRequest.java index 9b5d3500e1..3fe9e10fa0 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/HealthRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/HealthRequest.java @@ -61,7 +61,7 @@ // typedef: cat.health.Request /** - * Get the cluster health status. + * Get a compact cluster health summary. *

* 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 diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/IndicesRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/IndicesRequest.java index ac7b459ce6..8ba9a9d765 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/IndicesRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/IndicesRequest.java @@ -63,7 +63,7 @@ // typedef: cat.indices.Request /** - * Get index information. + * Get a compact list of indices. *

* Get high-level information about indices in a cluster, including backing * indices for data streams. @@ -169,7 +169,10 @@ public final Bytes bytes() { } /** - * The type of index that wildcard patterns can match. + * The type of index that wildcard patterns can match. Note that + * closed also matches non-hidden data streams, so their open + * backing indices are returned as well. It does not restrict the response to + * closed indices only. *

* API name: {@code expand_wildcards} */ @@ -340,7 +343,10 @@ public final Builder bytes(@Nullable Bytes value) { } /** - * The type of index that wildcard patterns can match. + * The type of index that wildcard patterns can match. Note that + * closed also matches non-hidden data streams, so their open + * backing indices are returned as well. It does not restrict the response to + * closed indices only. *

* API name: {@code expand_wildcards} *

@@ -352,7 +358,10 @@ public final Builder expandWildcards(List list) { } /** - * The type of index that wildcard patterns can match. + * The type of index that wildcard patterns can match. Note that + * closed also matches non-hidden data streams, so their open + * backing indices are returned as well. It does not restrict the response to + * closed indices only. *

* API name: {@code expand_wildcards} *

diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/NodesRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/NodesRequest.java index 421860c56c..323cb33baa 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/NodesRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/NodesRequest.java @@ -62,7 +62,7 @@ // typedef: cat.nodes.Request /** - * Get node information. + * Get a compact list of nodes. *

* Get information about the nodes in a cluster. IMPORTANT: cat APIs are only * intended for human consumption using the command line or Kibana console. They diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/RepositoriesRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/RepositoriesRequest.java index e55abf808c..b464bda78c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/RepositoriesRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/RepositoriesRequest.java @@ -61,7 +61,7 @@ // typedef: cat.repositories.Request /** - * Get snapshot repository information. + * Get a compact list of snapshot repositories. *

* Get a list of snapshot repositories for a cluster. IMPORTANT: cat APIs are * only intended for human consumption using the command line or Kibana console. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/SnapshotsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/SnapshotsRequest.java index 523bc1d86e..fda9e11aad 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/SnapshotsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/SnapshotsRequest.java @@ -61,7 +61,7 @@ // typedef: cat.snapshots.Request /** - * Get snapshot information. + * Get a compact list of snapshots. *

* Get information about the snapshots stored in one or more repositories. A * snapshot is a backup of an index or running Elasticsearch cluster. IMPORTANT: diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/TasksRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/TasksRequest.java index 06a3ce6f9e..8ead1ac7b9 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/TasksRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/TasksRequest.java @@ -62,7 +62,7 @@ // typedef: cat.tasks.Request /** - * Get task information. + * Get a compact list of running tasks. *

* Get information about tasks currently running in the cluster. IMPORTANT: cat * APIs are only intended for human consumption using the command line or Kibana diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ClusterInfoRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ClusterInfoRequest.java index e8e8f18cd4..a5856a4e62 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ClusterInfoRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ClusterInfoRequest.java @@ -58,7 +58,7 @@ // typedef: cluster.info.Request /** - * Get cluster info. + * Get cluster subsystem info. *

* Returns basic information about the cluster. * diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ElasticsearchClusterAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ElasticsearchClusterAsyncClient.java index 9cca5bca50..8f32b33778 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ElasticsearchClusterAsyncClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ElasticsearchClusterAsyncClient.java @@ -472,7 +472,7 @@ public CompletableFuture health() { // ----- Endpoint: cluster.info /** - * Get cluster info. + * Get cluster subsystem info. *

* Returns basic information about the cluster. * @@ -489,7 +489,7 @@ public CompletableFuture info(ClusterInfoRequest request) { } /** - * Get cluster info. + * Get cluster subsystem info. *

* Returns basic information about the cluster. * diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ElasticsearchClusterClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ElasticsearchClusterClient.java index 0465f61838..98a2eba8c3 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ElasticsearchClusterClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/ElasticsearchClusterClient.java @@ -480,7 +480,7 @@ public HealthResponse health() throws IOException, ElasticsearchException { // ----- Endpoint: cluster.info /** - * Get cluster info. + * Get cluster subsystem info. *

* Returns basic information about the cluster. * @@ -497,7 +497,7 @@ public ClusterInfoResponse info(ClusterInfoRequest request) throws IOException, } /** - * Get cluster info. + * Get cluster subsystem info. *

* Returns basic information about the cluster. * diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibration.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibration.java new file mode 100644 index 0000000000..b4a9b4c256 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibration.java @@ -0,0 +1,265 @@ +/* + * 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.cluster.stats; + +import co.elastic.clients.json.JsonData; +import co.elastic.clients.json.JsonEnum; +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.JsonpUtils; +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.OpenTaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Object; +import java.util.Objects; +import java.util.function.Function; +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: cluster.stats.DenseVectorAutoCalibration + +/** + * The auto-calibration information of a dense_vector field, + * aggregated over the segments that share the same parameters. + *

+ * The shape of parameters depends on the quantization method of + * the field. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DenseVectorAutoCalibration + implements + OpenTaggedUnion, + JsonpSerializable { + + /** + * {@link DenseVectorAutoCalibration} variant kinds. + * + * @see API + * specification + */ + + public enum Kind implements JsonEnum { + Osq("osq"), + + /** A custom {@code DenseVectorAutoCalibration} defined by a plugin */ + _Custom(null) + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + public DenseVectorAutoCalibration(DenseVectorAutoCalibrationVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._denseVectorAutoCalibrationKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + this._customKind = null; + + } + + private DenseVectorAutoCalibration(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + this._customKind = builder._customKind; + + } + + public static DenseVectorAutoCalibration of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Build a custom plugin-defined {@code DenseVectorAutoCalibration}, given its + * kind and some JSON data + */ + public DenseVectorAutoCalibration(String kind, JsonData value) { + this._kind = Kind._Custom; + this._value = value; + this._customKind = kind; + } + + /** + * Is this variant instance of kind {@code osq}? + */ + public boolean isOsq() { + return _kind == Kind.Osq; + } + + /** + * Get the {@code osq} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code osq} kind. + */ + public OsqDenseVectorAutoCalibration osq() { + return TaggedUnionUtils.get(this, Kind.Osq); + } + + @Nullable + private final String _customKind; + + /** + * Is this a custom {@code DenseVectorAutoCalibration} defined by a plugin? + */ + public boolean _isCustom() { + return _kind == Kind._Custom; + } + + /** + * Get the actual kind when {@code _kind()} equals {@link Kind#_Custom} + * (plugin-defined variant). + */ + @Nullable + public final String _customKind() { + return _customKind; + } + + /** + * Get the custom plugin-defined variant value. + * + * @throws IllegalStateException + * if the current variant is not {@link Kind#_Custom}. + */ + public JsonData _custom() { + return TaggedUnionUtils.get(this, Kind._Custom); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + + mapper.serialize(_value, generator); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Kind _kind; + private Object _value; + private String _customKind; + + @Override + protected Builder self() { + return this; + } + public ObjectBuilder osq(OsqDenseVectorAutoCalibration v) { + this._kind = Kind.Osq; + this._value = v; + return this; + } + + public ObjectBuilder osq( + Function> fn) { + return this.osq(fn.apply(new OsqDenseVectorAutoCalibration.Builder()).build()); + } + + /** + * Define this {@code DenseVectorAutoCalibration} as a plugin-defined variant. + * + * @param name + * the plugin-defined identifier + * @param data + * the data for this custom {@code DenseVectorAutoCalibration}. It is + * converted internally to {@link JsonData}. + */ + public ObjectBuilder _custom(String name, Object data) { + this._kind = Kind._Custom; + this._customKind = name; + this._value = JsonData.of(data); + return this; + } + + public DenseVectorAutoCalibration build() { + _checkSingleUse(); + return new DenseVectorAutoCalibration(this); + } + + } + + protected static void setupDenseVectorAutoCalibrationDeserializer(ObjectDeserializer op) { + + op.add(Builder::osq, OsqDenseVectorAutoCalibration._DESERIALIZER, "osq"); + + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + JsonpUtils.ensureCustomVariantsAllowed(parser, mapper); + builder._custom(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); + + op.setTypeProperty("type", null); + + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, DenseVectorAutoCalibration::setupDenseVectorAutoCalibrationDeserializer, Builder::build); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibrationBase.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibrationBase.java new file mode 100644 index 0000000000..5d0d2e0554 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibrationBase.java @@ -0,0 +1,113 @@ +/* + * 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.cluster.stats; + +import co.elastic.clients.elasticsearch.indices.segments.SegmentAutoCalibrationBase; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +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.util.Objects; + +//---------------------------------------------------------------- +// 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: cluster.stats.DenseVectorAutoCalibrationBase + +/** + * + * @see API + * specification + */ + +public abstract class DenseVectorAutoCalibrationBase extends SegmentAutoCalibrationBase { + private final int numberOfSegments; + + // --------------------------------------------------------------------------------------------- + + protected DenseVectorAutoCalibrationBase(AbstractBuilder builder) { + super(builder); + + this.numberOfSegments = ApiTypeHelper.requireNonNull(builder.numberOfSegments, this, "numberOfSegments", 0); + + } + + /** + * Required - The number of segments that share these parameters. + *

+ * API name: {@code number_of_segments} + */ + public final int numberOfSegments() { + return this.numberOfSegments; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + generator.writeKey("number_of_segments"); + generator.write(this.numberOfSegments); + + } + + public abstract static class AbstractBuilder> + extends + SegmentAutoCalibrationBase.AbstractBuilder { + private Integer numberOfSegments; + + /** + * Required - The number of segments that share these parameters. + *

+ * API name: {@code number_of_segments} + */ + public final BuilderT numberOfSegments(int value) { + this.numberOfSegments = value; + return self(); + } + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupDenseVectorAutoCalibrationBaseDeserializer( + ObjectDeserializer op) { + SegmentAutoCalibrationBase.setupSegmentAutoCalibrationBaseDeserializer(op); + op.add(AbstractBuilder::numberOfSegments, JsonpDeserializer.integerDeserializer(), "number_of_segments"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibrationBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibrationBuilders.java new file mode 100644 index 0000000000..4a20722163 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibrationBuilders.java @@ -0,0 +1,67 @@ +/* + * 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.cluster.stats; + +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link DenseVectorAutoCalibration} variants. + */ +public class DenseVectorAutoCalibrationBuilders { + private DenseVectorAutoCalibrationBuilders() { + } + + /** + * Creates a builder for the {@link OsqDenseVectorAutoCalibration osq} + * {@code DenseVectorAutoCalibration} variant. + */ + public static OsqDenseVectorAutoCalibration.Builder osq() { + return new OsqDenseVectorAutoCalibration.Builder(); + } + + /** + * Creates a DenseVectorAutoCalibration of the + * {@link OsqDenseVectorAutoCalibration osq} {@code DenseVectorAutoCalibration} + * variant. + */ + public static DenseVectorAutoCalibration osq( + Function> fn) { + DenseVectorAutoCalibration.Builder builder = new DenseVectorAutoCalibration.Builder(); + builder.osq(fn.apply(new OsqDenseVectorAutoCalibration.Builder()).build()); + return builder.build(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibrationVariant.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibrationVariant.java new file mode 100644 index 0000000000..9625fa8c88 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorAutoCalibrationVariant.java @@ -0,0 +1,50 @@ +/* + * 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.cluster.stats; + +import co.elastic.clients.json.JsonpSerializable; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Base interface for {@link DenseVectorAutoCalibration} variants. + */ +public interface DenseVectorAutoCalibrationVariant extends JsonpSerializable { + + DenseVectorAutoCalibration.Kind _denseVectorAutoCalibrationKind(); + + default DenseVectorAutoCalibration _toDenseVectorAutoCalibration() { + return new DenseVectorAutoCalibration(this); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorFieldOffHeapStats.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorFieldOffHeapStats.java new file mode 100644 index 0000000000..b2a4a51491 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorFieldOffHeapStats.java @@ -0,0 +1,270 @@ +/* + * 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.cluster.stats; + +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.JsonpUtils; +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.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: cluster.stats.DenseVectorFieldOffHeapStats + +/** + * The off-heap stats of a dense_vector field. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DenseVectorFieldOffHeapStats implements JsonpSerializable { + private final Map sizes; + + private final List autoCalibration; + + // --------------------------------------------------------------------------------------------- + + private DenseVectorFieldOffHeapStats(Builder builder) { + + this.sizes = ApiTypeHelper.unmodifiable(builder.sizes); + + this.autoCalibration = ApiTypeHelper.unmodifiable(builder.autoCalibration); + + } + + public static DenseVectorFieldOffHeapStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The off-heap sizes of the field, keyed by file extension, such as + * vec_size_bytes. + */ + public final Map sizes() { + return this.sizes; + } + + /** + * The auto-calibration information of the field, aggregated by distinct set of + * parameters. Only returned when include_auto_calibration is + * true. + *

+ * API name: {@code auto_calibration} + */ + public final List autoCalibration() { + return this.autoCalibration; + } + + /** + * 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) { + + for (Map.Entry item0 : this.sizes.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); + + } + + if (ApiTypeHelper.isDefined(this.autoCalibration)) { + generator.writeKey("auto_calibration"); + generator.writeStartArray(); + for (DenseVectorAutoCalibration item0 : this.autoCalibration) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DenseVectorFieldOffHeapStats}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private Map sizes = new HashMap<>(); + + /** + * The off-heap sizes of the field, keyed by file extension, such as + * vec_size_bytes. + *

+ * Adds all entries of map to sizes. + */ + public final Builder sizes(Map map) { + this.sizes = _mapPutAll(this.sizes, map); + return this; + } + + /** + * The off-heap sizes of the field, keyed by file extension, such as + * vec_size_bytes. + *

+ * Adds an entry to sizes. + */ + public final Builder sizes(String key, Long value) { + this.sizes = _mapPut(this.sizes, key, value); + return this; + } + + @Nullable + private List autoCalibration; + + public Builder() { + } + private Builder(DenseVectorFieldOffHeapStats instance) { + this.autoCalibration = instance.autoCalibration; + this.sizes = instance.sizes; + + } + /** + * The auto-calibration information of the field, aggregated by distinct set of + * parameters. Only returned when include_auto_calibration is + * true. + *

+ * API name: {@code auto_calibration} + *

+ * Adds all elements of list to autoCalibration. + */ + public final Builder autoCalibration(List list) { + this.autoCalibration = _listAddAll(this.autoCalibration, list); + return this; + } + + /** + * The auto-calibration information of the field, aggregated by distinct set of + * parameters. Only returned when include_auto_calibration is + * true. + *

+ * API name: {@code auto_calibration} + *

+ * Adds one or more values to autoCalibration. + */ + public final Builder autoCalibration(DenseVectorAutoCalibration value, DenseVectorAutoCalibration... values) { + this.autoCalibration = _listAdd(this.autoCalibration, value, values); + return this; + } + + /** + * The auto-calibration information of the field, aggregated by distinct set of + * parameters. Only returned when include_auto_calibration is + * true. + *

+ * API name: {@code auto_calibration} + *

+ * Adds a value to autoCalibration using a builder lambda. + */ + public final Builder autoCalibration( + Function> fn) { + return autoCalibration(fn.apply(new DenseVectorAutoCalibration.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DenseVectorFieldOffHeapStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DenseVectorFieldOffHeapStats build() { + _checkSingleUse(); + + return new DenseVectorFieldOffHeapStats(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DenseVectorFieldOffHeapStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DenseVectorFieldOffHeapStats::setupDenseVectorFieldOffHeapStatsDeserializer); + + protected static void setupDenseVectorFieldOffHeapStatsDeserializer( + ObjectDeserializer op) { + + op.add(Builder::autoCalibration, JsonpDeserializer.arrayDeserializer(DenseVectorAutoCalibration._DESERIALIZER), + "auto_calibration"); + + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + builder.sizes(name, JsonpDeserializer.longDeserializer().deserialize(parser, mapper)); + }); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorOffHeapStats.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorOffHeapStats.java index 25235fe928..e5a1131227 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorOffHeapStats.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/DenseVectorOffHeapStats.java @@ -97,7 +97,7 @@ public class DenseVectorOffHeapStats implements JsonpSerializable { @Nullable private final String totalClivfSize; - private final Map> fielddata; + private final Map fielddata; // --------------------------------------------------------------------------------------------- @@ -235,7 +235,7 @@ public final String totalClivfSize() { /** * API name: {@code fielddata} */ - public final Map> fielddata() { + public final Map fielddata() { return this.fielddata; } @@ -309,17 +309,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.fielddata)) { generator.writeKey("fielddata"); generator.writeStartObject(); - for (Map.Entry> item0 : this.fielddata.entrySet()) { + for (Map.Entry item0 : this.fielddata.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartObject(); - if (item0.getValue() != null) { - for (Map.Entry item1 : item0.getValue().entrySet()) { - generator.writeKey(item1.getKey()); - generator.write(item1.getValue()); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -378,7 +370,7 @@ public static class Builder extends WithJsonObjectBuilderBase private String totalClivfSize; @Nullable - private Map> fielddata; + private Map fielddata; public Builder() { } @@ -517,7 +509,7 @@ public final Builder totalClivfSize(@Nullable String value) { *

* Adds all entries of map to fielddata. */ - public final Builder fielddata(Map> map) { + public final Builder fielddata(Map map) { this.fielddata = _mapPutAll(this.fielddata, map); return this; } @@ -527,11 +519,21 @@ public final Builder fielddata(Map> map) { *

* Adds an entry to fielddata. */ - public final Builder fielddata(String key, Map value) { + public final Builder fielddata(String key, DenseVectorFieldOffHeapStats value) { this.fielddata = _mapPut(this.fielddata, key, value); return this; } + /** + * API name: {@code fielddata} + *

+ * Adds an entry to fielddata using a builder lambda. + */ + public final Builder fielddata(String key, + Function> fn) { + return fielddata(key, fn.apply(new DenseVectorFieldOffHeapStats.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -581,8 +583,8 @@ protected static void setupDenseVectorOffHeapStatsDeserializer( op.add(Builder::totalCenivfSize, JsonpDeserializer.stringDeserializer(), "total_cenivf_size"); op.add(Builder::totalClivfSizeBytes, JsonpDeserializer.longDeserializer(), "total_clivf_size_bytes"); op.add(Builder::totalClivfSize, JsonpDeserializer.stringDeserializer(), "total_clivf_size"); - op.add(Builder::fielddata, JsonpDeserializer.stringMapDeserializer( - JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.longDeserializer())), "fielddata"); + op.add(Builder::fielddata, JsonpDeserializer.stringMapDeserializer(DenseVectorFieldOffHeapStats._DESERIALIZER), + "fielddata"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/OsqDenseVectorAutoCalibration.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/OsqDenseVectorAutoCalibration.java new file mode 100644 index 0000000000..e23238e689 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cluster/stats/OsqDenseVectorAutoCalibration.java @@ -0,0 +1,185 @@ +/* + * 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.cluster.stats; + +import co.elastic.clients.elasticsearch.indices.segments.OsqSegmentAutoCalibrationParameters; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +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: cluster.stats.OsqDenseVectorAutoCalibration + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class OsqDenseVectorAutoCalibration extends DenseVectorAutoCalibrationBase + implements + DenseVectorAutoCalibrationVariant { + @Nullable + private final OsqSegmentAutoCalibrationParameters parameters; + + // --------------------------------------------------------------------------------------------- + + private OsqDenseVectorAutoCalibration(Builder builder) { + super(builder); + + this.parameters = builder.parameters; + + } + + public static OsqDenseVectorAutoCalibration of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * DenseVectorAutoCalibration variant kind. + */ + @Override + public DenseVectorAutoCalibration.Kind _denseVectorAutoCalibrationKind() { + return DenseVectorAutoCalibration.Kind.Osq; + } + + /** + * The calibration parameters. + *

+ * API name: {@code parameters} + */ + @Nullable + public final OsqSegmentAutoCalibrationParameters parameters() { + return this.parameters; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "osq"); + super.serializeInternal(generator, mapper); + if (this.parameters != null) { + generator.writeKey("parameters"); + this.parameters.serialize(generator, mapper); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link OsqDenseVectorAutoCalibration}. + */ + + public static class Builder extends DenseVectorAutoCalibrationBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private OsqSegmentAutoCalibrationParameters parameters; + + public Builder() { + } + private Builder(OsqDenseVectorAutoCalibration instance) { + this.parameters = instance.parameters; + + } + /** + * The calibration parameters. + *

+ * API name: {@code parameters} + */ + public final Builder parameters(@Nullable OsqSegmentAutoCalibrationParameters value) { + this.parameters = value; + return this; + } + + /** + * The calibration parameters. + *

+ * API name: {@code parameters} + */ + public final Builder parameters( + Function> fn) { + return this.parameters(fn.apply(new OsqSegmentAutoCalibrationParameters.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link OsqDenseVectorAutoCalibration}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public OsqDenseVectorAutoCalibration build() { + _checkSingleUse(); + + return new OsqDenseVectorAutoCalibration(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link OsqDenseVectorAutoCalibration} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, OsqDenseVectorAutoCalibration::setupOsqDenseVectorAutoCalibrationDeserializer); + + protected static void setupOsqDenseVectorAutoCalibrationDeserializer( + ObjectDeserializer op) { + DenseVectorAutoCalibrationBase.setupDenseVectorAutoCalibrationBaseDeserializer(op); + op.add(Builder::parameters, OsqSegmentAutoCalibrationParameters._DESERIALIZER, "parameters"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/BulkRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/BulkRequest.java index b6d233808b..c9cdba39a1 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/BulkRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/BulkRequest.java @@ -426,11 +426,9 @@ public final Boolean requireDataStream() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The default slice identifier for a slice-enabled index + * (index.slice.enabled set to true), applied to the + * items that do not specify their own _slice. *

* API name: {@code _slice} */ @@ -734,11 +732,9 @@ public final Builder requireDataStream(@Nullable Boolean value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The default slice identifier for a slice-enabled index + * (index.slice.enabled set to true), applied to the + * items that do not specify their own _slice. *

* API name: {@code _slice} */ @@ -910,11 +906,14 @@ public Builder rebuild() { // Request path request -> { final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (request.index() != null) propsSet |= _index; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); @@ -928,6 +927,15 @@ public Builder rebuild() { buf.append("/_bulk"); return buf.toString(); } + if (propsSet == (_index | _routeSlice)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_bulk"); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -936,41 +944,30 @@ public Builder rebuild() { request -> { Map params = new HashMap<>(); final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (request.index() != null) propsSet |= _index; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == 0) { } if (propsSet == (_index)) { params.put("index", request.index); } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + } return params; }, // Request parameters request -> { Map params = new HashMap<>(); - if (request.includeSourceOnError != null) { - params.put("include_source_on_error", String.valueOf(request.includeSourceOnError)); - } - if (request.refresh != null) { - params.put("refresh", request.refresh.jsonValue()); - } - if (request.routeSlice != null) { - params.put("_slice", request.routeSlice); - } - if (request.requireDataStream != null) { - params.put("require_data_stream", String.valueOf(request.requireDataStream)); - } - if (request.listExecutedPipelines != null) { - params.put("list_executed_pipelines", String.valueOf(request.listExecutedPipelines)); - } - if (request.timeout != null) { - params.put("timeout", request.timeout._toJsonString()); - } if (request.pipeline != null) { params.put("pipeline", request.pipeline); } @@ -978,9 +975,15 @@ public Builder rebuild() { params.put("routing", request.routing.stream().map(v -> v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (request.includeSourceOnError != null) { + params.put("include_source_on_error", String.valueOf(request.includeSourceOnError)); + } if (request.requireAlias != null) { params.put("require_alias", String.valueOf(request.requireAlias)); } + if (request.refresh != null) { + params.put("refresh", request.refresh.jsonValue()); + } if (request.waitForActiveShards != null) { params.put("wait_for_active_shards", request.waitForActiveShards._toJsonString()); } @@ -995,6 +998,15 @@ public Builder rebuild() { params.put("_source_includes", request.sourceIncludes.stream().map(v -> v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (request.requireDataStream != null) { + params.put("require_data_stream", String.valueOf(request.requireDataStream)); + } + if (request.listExecutedPipelines != null) { + params.put("list_executed_pipelines", String.valueOf(request.listExecutedPipelines)); + } + if (request.timeout != null) { + params.put("timeout", request.timeout._toJsonString()); + } return params; }, SimpleEndpoint.emptyMap(), true, BulkResponse._DESERIALIZER); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/CountRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/CountRequest.java index cebef3f932..33a9b4f47e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/CountRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/CountRequest.java @@ -130,8 +130,7 @@ public class CountRequest extends RequestBase implements JsonpSerializable { @Nullable private final Query query; - @Nullable - private final String routeSlice; + private final List routeSlice; private final List routing; @@ -159,7 +158,7 @@ private CountRequest(Builder builder) { this.projectRouting = builder.projectRouting; this.q = builder.q; this.query = builder.query; - this.routeSlice = builder.routeSlice; + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); this.stats = ApiTypeHelper.unmodifiable(builder.stats); this.terminateAfter = builder.terminateAfter; @@ -353,16 +352,16 @@ public final Query query() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. *

* API name: {@code _slice} */ - @Nullable - public final String routeSlice() { + public final List routeSlice() { return this.routeSlice; } @@ -481,7 +480,7 @@ public static class Builder extends RequestBase.AbstractBuilder impleme private Query query; @Nullable - private String routeSlice; + private List routeSlice; @Nullable private List routing; @@ -755,16 +754,36 @@ public final Builder query(QueryVariant value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. *

* API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. */ - public final Builder routeSlice(@Nullable String value) { - this.routeSlice = value; + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. + *

+ * API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. + */ + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); return this; } @@ -895,11 +914,14 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer { final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); @@ -914,6 +936,17 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/_count"); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -922,11 +955,14 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer { Map params = new HashMap<>(); final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == 0) { } @@ -934,6 +970,12 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + params.put("routeSlice", request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } return params; }, @@ -956,9 +998,6 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer extends RequestBase implements JsonpSerial @Nullable private final Boolean requireDataStream; + @Nullable + private final String routeSlice; + private final List routing; @Nullable @@ -248,6 +251,7 @@ private CreateRequest(Builder builder) { this.refresh = builder.refresh; this.requireAlias = builder.requireAlias; this.requireDataStream = builder.requireDataStream; + this.routeSlice = builder.routeSlice; this.routing = ApiTypeHelper.unmodifiable(builder.routing); this.timeout = builder.timeout; this.version = builder.version; @@ -346,7 +350,23 @@ public final Boolean requireDataStream() { } /** - * A custom value that is used to route operations to a specific shard. + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is + * true for the target index; not allowed when + * index.slice.enabled is false. + *

+ * API name: {@code _slice} + */ + @Nullable + public final String routeSlice() { + return this.routeSlice; + } + + /** + * A custom value that is used to route operations to a specific shard. Not + * allowed when index.slice.enabled is true for the + * target index; use _slice instead. *

* API name: {@code routing} */ @@ -453,6 +473,9 @@ public static class Builder extends RequestBase.AbstractBuilder routing; @@ -483,6 +506,7 @@ private Builder(CreateRequest instance) { this.refresh = instance.refresh; this.requireAlias = instance.requireAlias; this.requireDataStream = instance.requireDataStream; + this.routeSlice = instance.routeSlice; this.routing = instance.routing; this.timeout = instance.timeout; this.version = instance.version; @@ -576,7 +600,23 @@ public final Builder requireDataStream(@Nullable Boolean value) { } /** - * A custom value that is used to route operations to a specific shard. + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is + * true for the target index; not allowed when + * index.slice.enabled is false. + *

+ * API name: {@code _slice} + */ + public final Builder routeSlice(@Nullable String value) { + this.routeSlice = value; + return this; + } + + /** + * A custom value that is used to route operations to a specific shard. Not + * allowed when index.slice.enabled is true for the + * target index; use _slice instead. *

* API name: {@code routing} *

@@ -588,7 +628,9 @@ public final Builder routing(List list) { } /** - * A custom value that is used to route operations to a specific shard. + * A custom value that is used to route operations to a specific shard. Not + * allowed when index.slice.enabled is true for the + * target index; use _slice instead. *

* API name: {@code routing} *

@@ -774,11 +816,14 @@ public static JsonpDeserializer> createCrea request -> { final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { StringBuilder buf = new StringBuilder(); @@ -789,6 +834,17 @@ public static JsonpDeserializer> createCrea SimpleEndpoint.pathEncode(request.id, buf); return buf.toString(); } + if (propsSet == (_index | _routeSlice | _id)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_create"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.id, buf); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -798,16 +854,24 @@ public static JsonpDeserializer> createCrea Map params = new HashMap<>(); final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { params.put("index", request.index); params.put("id", request.id); } + if (propsSet == (_index | _routeSlice | _id)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + params.put("id", request.id); + } return params; }, diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/DeleteByQueryRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/DeleteByQueryRequest.java index 8035031e85..e6bc40ab9a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/DeleteByQueryRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/DeleteByQueryRequest.java @@ -29,6 +29,7 @@ import co.elastic.clients.elasticsearch._types.SortOptions; import co.elastic.clients.elasticsearch._types.Time; import co.elastic.clients.elasticsearch._types.WaitForActiveShards; +import co.elastic.clients.elasticsearch._types.mapping.RuntimeField; import co.elastic.clients.elasticsearch._types.query_dsl.Operator; import co.elastic.clients.elasticsearch._types.query_dsl.Query; import co.elastic.clients.elasticsearch._types.query_dsl.QueryVariant; @@ -261,11 +262,12 @@ public class DeleteByQueryRequest extends RequestBase implements JsonpSerializab @Nullable private final Float requestsPerSecond; - @Nullable - private final String routeSlice; + private final List routeSlice; private final List routing; + private final Map runtimeMappings; + @Nullable private final Time scroll; @@ -325,8 +327,9 @@ private DeleteByQueryRequest(Builder builder) { this.refresh = builder.refresh; this.requestCache = builder.requestCache; this.requestsPerSecond = builder.requestsPerSecond; - this.routeSlice = builder.routeSlice; + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); + this.runtimeMappings = ApiTypeHelper.unmodifiable(builder.runtimeMappings); this.scroll = builder.scroll; this.scrollSize = builder.scrollSize; this.searchTimeout = builder.searchTimeout; @@ -559,16 +562,14 @@ public final Float requestsPerSecond() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. *

* API name: {@code _slice} */ - @Nullable - public final String routeSlice() { + public final List routeSlice() { return this.routeSlice; } @@ -583,6 +584,16 @@ public final List routing() { return this.routing; } + /** + * One or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + */ + public final Map runtimeMappings() { + return this.runtimeMappings; + } + /** * The period to retain the search context for scrolling. *

@@ -750,6 +761,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("query"); this.query.serialize(generator, mapper); + } + if (ApiTypeHelper.isDefined(this.runtimeMappings)) { + generator.writeKey("runtime_mappings"); + generator.writeStartObject(); + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + } if (this.slice != null) { generator.writeKey("slice"); @@ -832,11 +854,14 @@ public static class Builder extends RequestBase.AbstractBuilder private Float requestsPerSecond; @Nullable - private String routeSlice; + private List routeSlice; @Nullable private List routing; + @Nullable + private Map runtimeMappings; + @Nullable private Time scroll; @@ -899,6 +924,7 @@ private Builder(DeleteByQueryRequest instance) { this.requestsPerSecond = instance.requestsPerSecond; this.routeSlice = instance.routeSlice; this.routing = instance.routing; + this.runtimeMappings = instance.runtimeMappings; this.scroll = instance.scroll; this.scrollSize = instance.scrollSize; this.searchTimeout = instance.searchTimeout; @@ -1180,16 +1206,32 @@ public final Builder requestsPerSecond(@Nullable Float value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. *

* API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. + */ + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. + *

+ * API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. */ - public final Builder routeSlice(@Nullable String value) { - this.routeSlice = value; + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); return this; } @@ -1221,6 +1263,45 @@ public final Builder routing(String value, String... values) { return this; } + /** + * One or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds all entries of map to runtimeMappings. + */ + public final Builder runtimeMappings(Map map) { + this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); + return this; + } + + /** + * One or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings. + */ + public final Builder runtimeMappings(String key, RuntimeField value) { + this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); + return this; + } + + /** + * One or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * The period to retain the search context for scrolling. *

@@ -1506,6 +1587,8 @@ protected static void setupDeleteByQueryRequestDeserializer(ObjectDeserializer { final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); @@ -1541,6 +1627,17 @@ protected static void setupDeleteByQueryRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/_delete_by_query"); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -1549,15 +1646,24 @@ protected static void setupDeleteByQueryRequestDeserializer(ObjectDeserializer { Map params = new HashMap<>(); final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == (_index)) { params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + params.put("routeSlice", request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } return params; }, @@ -1630,9 +1736,6 @@ protected static void setupDeleteByQueryRequestDeserializer(ObjectDeserializer failures; + private final List failures; @Nullable private final Long noops; @@ -176,7 +176,7 @@ public final Long deleted() { *

* API name: {@code failures} */ - public final List failures() { + public final List failures() { return this.failures; } @@ -344,7 +344,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.failures)) { generator.writeKey("failures"); generator.writeStartArray(); - for (BulkIndexByScrollFailure item0 : this.failures) { + for (BulkByPaginatedSearchFailure item0 : this.failures) { item0.serialize(generator, mapper); } @@ -450,7 +450,7 @@ public static class Builder extends WithJsonObjectBuilderBase private Long deleted; @Nullable - private List failures; + private List failures; @Nullable private Long noops; @@ -526,7 +526,7 @@ public final Builder deleted(@Nullable Long value) { *

* Adds all elements of list to failures. */ - public final Builder failures(List list) { + public final Builder failures(List list) { this.failures = _listAddAll(this.failures, list); return this; } @@ -543,7 +543,7 @@ public final Builder failures(List list) { *

* Adds one or more values to failures. */ - public final Builder failures(BulkIndexByScrollFailure value, BulkIndexByScrollFailure... values) { + public final Builder failures(BulkByPaginatedSearchFailure value, BulkByPaginatedSearchFailure... values) { this.failures = _listAdd(this.failures, value, values); return this; } @@ -561,8 +561,8 @@ public final Builder failures(BulkIndexByScrollFailure value, BulkIndexByScrollF * Adds a value to failures using a builder lambda. */ public final Builder failures( - Function> fn) { - return failures(fn.apply(new BulkIndexByScrollFailure.Builder()).build()); + Function> fn) { + return failures(fn.apply(new BulkByPaginatedSearchFailure.Builder()).build()); } /** @@ -786,7 +786,7 @@ protected static void setupDeleteByQueryResponseDeserializer(ObjectDeserializer< op.add(Builder::batches, JsonpDeserializer.longDeserializer(), "batches"); op.add(Builder::deleted, JsonpDeserializer.longDeserializer(), "deleted"); - op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(BulkIndexByScrollFailure._DESERIALIZER), + op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(BulkByPaginatedSearchFailure._DESERIALIZER), "failures"); op.add(Builder::noops, JsonpDeserializer.longDeserializer(), "noops"); op.add(Builder::requestsPerSecond, JsonpDeserializer.floatDeserializer(), "requests_per_second"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/DeleteRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/DeleteRequest.java index 79ed079857..c769415816 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/DeleteRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/DeleteRequest.java @@ -223,9 +223,9 @@ public final Refresh refresh() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -407,9 +407,9 @@ public final Builder refresh(@Nullable Refresh value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -572,11 +572,14 @@ public Builder rebuild() { request -> { final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { StringBuilder buf = new StringBuilder(); @@ -587,6 +590,17 @@ public Builder rebuild() { SimpleEndpoint.pathEncode(request.id, buf); return buf.toString(); } + if (propsSet == (_index | _routeSlice | _id)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_doc"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.id, buf); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -596,16 +610,24 @@ public Builder rebuild() { Map params = new HashMap<>(); final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { params.put("index", request.index); params.put("id", request.id); } + if (propsSet == (_index | _routeSlice | _id)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + params.put("id", request.id); + } return params; }, @@ -631,9 +653,6 @@ public Builder rebuild() { if (request.waitForActiveShards != null) { params.put("wait_for_active_shards", request.waitForActiveShards._toJsonString()); } - if (request.routeSlice != null) { - params.put("_slice", request.routeSlice); - } if (request.version != null) { params.put("version", String.valueOf(request.version)); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/ExistsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/ExistsRequest.java index ee343d2791..a346b4016c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/ExistsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/ExistsRequest.java @@ -112,6 +112,9 @@ public class ExistsRequest extends RequestBase { @Nullable private final Boolean refresh; + @Nullable + private final String routeSlice; + private final List routing; private final List storedFields; @@ -134,6 +137,7 @@ private ExistsRequest(Builder builder) { this.preference = builder.preference; this.realtime = builder.realtime; this.refresh = builder.refresh; + this.routeSlice = builder.routeSlice; this.routing = ApiTypeHelper.unmodifiable(builder.routing); this.storedFields = ApiTypeHelper.unmodifiable(builder.storedFields); this.version = builder.version; @@ -242,7 +246,23 @@ public final Boolean refresh() { } /** - * A custom value used to route operations to a specific shard. + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is + * true for the target index; not allowed when + * index.slice.enabled is false. + *

+ * API name: {@code _slice} + */ + @Nullable + public final String routeSlice() { + return this.routeSlice; + } + + /** + * A custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. *

* API name: {@code routing} */ @@ -312,6 +332,9 @@ public static class Builder extends RequestBase.AbstractBuilder impleme @Nullable private Boolean refresh; + @Nullable + private String routeSlice; + @Nullable private List routing; @@ -335,6 +358,7 @@ private Builder(ExistsRequest instance) { this.preference = instance.preference; this.realtime = instance.realtime; this.refresh = instance.refresh; + this.routeSlice = instance.routeSlice; this.routing = instance.routing; this.storedFields = instance.storedFields; this.version = instance.version; @@ -487,7 +511,23 @@ public final Builder refresh(@Nullable Boolean value) { } /** - * A custom value used to route operations to a specific shard. + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is + * true for the target index; not allowed when + * index.slice.enabled is false. + *

+ * API name: {@code _slice} + */ + public final Builder routeSlice(@Nullable String value) { + this.routeSlice = value; + return this; + } + + /** + * A custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. *

* API name: {@code routing} *

@@ -499,7 +539,9 @@ public final Builder routing(List list) { } /** - * A custom value used to route operations to a specific shard. + * A custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. *

* API name: {@code routing} *

@@ -603,11 +645,14 @@ public Builder rebuild() { request -> { final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { StringBuilder buf = new StringBuilder(); @@ -618,6 +663,17 @@ public Builder rebuild() { SimpleEndpoint.pathEncode(request.id, buf); return buf.toString(); } + if (propsSet == (_index | _routeSlice | _id)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_doc"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.id, buf); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -627,16 +683,24 @@ public Builder rebuild() { Map params = new HashMap<>(); final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { params.put("index", request.index); params.put("id", request.id); } + if (propsSet == (_index | _routeSlice | _id)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + params.put("id", request.id); + } return params; }, diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/ExplainRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/ExplainRequest.java index 199d000a8e..95d0c1c82f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/ExplainRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/ExplainRequest.java @@ -289,9 +289,9 @@ public final Query query() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -629,9 +629,9 @@ public final Builder query(QueryVariant value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -749,11 +749,14 @@ protected static void setupExplainRequestDeserializer(ObjectDeserializer { final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { StringBuilder buf = new StringBuilder(); @@ -764,6 +767,17 @@ protected static void setupExplainRequestDeserializer(ObjectDeserializer params = new HashMap<>(); final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { params.put("index", request.index); params.put("id", request.id); } + if (propsSet == (_index | _routeSlice | _id)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + params.put("id", request.id); + } return params; }, // Request parameters request -> { Map params = new HashMap<>(); - if (request.df != null) { - params.put("df", request.df); - } - if (request.preference != null) { - params.put("preference", request.preference); - } - if (request.analyzeWildcard != null) { - params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); - } - if (request.routeSlice != null) { - params.put("_slice", request.routeSlice); - } - if (request.lenient != null) { - params.put("lenient", String.valueOf(request.lenient)); - } if (ApiTypeHelper.isDefined(request.routing)) { params.put("routing", request.routing.stream().map(v -> v).filter(Objects::nonNull) .collect(Collectors.joining(","))); @@ -811,6 +818,9 @@ protected static void setupExplainRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (request.preference != null) { + params.put("preference", request.preference); + } + if (request.analyzeWildcard != null) { + params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); + } if (request.source != null) { params.put("_source", request.source._toJsonString()); } @@ -832,6 +848,9 @@ protected static void setupExplainRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (request.lenient != null) { + params.put("lenient", String.valueOf(request.lenient)); + } return params; }, SimpleEndpoint.emptyMap(), SimpleEndpoint.nonEmptyJsonObject(SimpleEndpoint.returnSelf()), diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/GetRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/GetRequest.java index 1adb076c49..ff23486e82 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/GetRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/GetRequest.java @@ -323,9 +323,9 @@ public final Boolean refresh() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -620,9 +620,9 @@ public final Builder refresh(@Nullable Boolean value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -757,11 +757,14 @@ public Builder rebuild() { request -> { final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { StringBuilder buf = new StringBuilder(); @@ -772,6 +775,17 @@ public Builder rebuild() { SimpleEndpoint.pathEncode(request.id, buf); return buf.toString(); } + if (propsSet == (_index | _routeSlice | _id)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_doc"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.id, buf); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -781,22 +795,34 @@ public Builder rebuild() { Map params = new HashMap<>(); final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { params.put("index", request.index); params.put("id", request.id); } + if (propsSet == (_index | _routeSlice | _id)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + params.put("id", request.id); + } return params; }, // Request parameters request -> { Map params = new HashMap<>(); + if (ApiTypeHelper.isDefined(request.routing)) { + params.put("routing", request.routing.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } if (request.realtime != null) { params.put("realtime", String.valueOf(request.realtime)); } @@ -806,29 +832,16 @@ public Builder rebuild() { if (request.sourceExcludeVectors != null) { params.put("_source_exclude_vectors", String.valueOf(request.sourceExcludeVectors)); } + if (ApiTypeHelper.isDefined(request.storedFields)) { + params.put("stored_fields", request.storedFields.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } if (request.preference != null) { params.put("preference", request.preference); } if (request.refresh != null) { params.put("refresh", String.valueOf(request.refresh)); } - if (request.forceSyntheticSource != null) { - params.put("force_synthetic_source", String.valueOf(request.forceSyntheticSource)); - } - if (request.routeSlice != null) { - params.put("_slice", request.routeSlice); - } - if (request.version != null) { - params.put("version", String.valueOf(request.version)); - } - if (ApiTypeHelper.isDefined(request.routing)) { - params.put("routing", request.routing.stream().map(v -> v).filter(Objects::nonNull) - .collect(Collectors.joining(","))); - } - if (ApiTypeHelper.isDefined(request.storedFields)) { - params.put("stored_fields", request.storedFields.stream().map(v -> v).filter(Objects::nonNull) - .collect(Collectors.joining(","))); - } if (request.source != null) { params.put("_source", request.source._toJsonString()); } @@ -836,10 +849,16 @@ public Builder rebuild() { params.put("_source_excludes", request.sourceExcludes.stream().map(v -> v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (request.forceSyntheticSource != null) { + params.put("force_synthetic_source", String.valueOf(request.forceSyntheticSource)); + } if (ApiTypeHelper.isDefined(request.sourceIncludes)) { params.put("_source_includes", request.sourceIncludes.stream().map(v -> v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (request.version != null) { + params.put("version", String.valueOf(request.version)); + } return params; }, SimpleEndpoint.emptyMap(), false, GetResponse._DESERIALIZER); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/IndexRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/IndexRequest.java index 23e42b8e1d..8802dc7e63 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/IndexRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/IndexRequest.java @@ -477,9 +477,9 @@ public final Boolean requireDataStream() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -776,9 +776,9 @@ public final Builder requireDataStream(@Nullable Boolean value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -982,17 +982,24 @@ public static JsonpDeserializer> createIndex request -> { final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; if (request.id() != null) propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) return "PUT"; if (propsSet == (_index)) return "POST"; + if (propsSet == (_index | _routeSlice | _id)) + return "PUT"; + if (propsSet == (_index | _routeSlice)) + return "POST"; throw SimpleEndpoint.noPathTemplateFound("method"); }, @@ -1001,12 +1008,15 @@ public static JsonpDeserializer> createIndex request -> { final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; if (request.id() != null) propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { StringBuilder buf = new StringBuilder(); @@ -1024,6 +1034,26 @@ public static JsonpDeserializer> createIndex buf.append("/_doc"); return buf.toString(); } + if (propsSet == (_index | _routeSlice | _id)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_doc"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.id, buf); + return buf.toString(); + } + if (propsSet == (_index | _routeSlice)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_doc"); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -1033,12 +1063,15 @@ public static JsonpDeserializer> createIndex Map params = new HashMap<>(); final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; if (request.id() != null) propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { params.put("index", request.index); @@ -1047,6 +1080,15 @@ public static JsonpDeserializer> createIndex if (propsSet == (_index)) { params.put("index", request.index); } + if (propsSet == (_index | _routeSlice | _id)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + params.put("id", request.id); + } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + } return params; }, @@ -1062,9 +1104,6 @@ public static JsonpDeserializer> createIndex if (request.refresh != null) { params.put("refresh", request.refresh.jsonValue()); } - if (request.routeSlice != null) { - params.put("_slice", request.routeSlice); - } if (request.version != null) { params.put("version", String.valueOf(request.version)); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/KnnEvalRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/KnnEvalRequest.java new file mode 100644 index 0000000000..992b85153b --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/KnnEvalRequest.java @@ -0,0 +1,667 @@ +/* + * 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.core; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.ExpandWildcard; +import co.elastic.clients.elasticsearch._types.RequestBase; +import co.elastic.clients.elasticsearch.core.knn_eval.KnnEvalQuerySource; +import co.elastic.clients.elasticsearch.core.knn_eval.KnnEvalSettings; +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.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.Integer; +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; + +//---------------------------------------------------------------- +// 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: _global.knn_eval.Request + +/** + * Evaluate kNN search settings. + *

+ * Estimate the recall and cost of approximate kNN search configurations on a + * dense_vector field against a more thorough baseline. The field + * must use the bbq_disk index type, and must not be inside a + * nested object. + *

+ * Each knn_settings entry reports the mean recall of the + * baseline's top k, not of relevance judgments, plus included and + * excluded query counts and cost totals. A query is excluded from the mean + * recall when the candidate finds a document scoring above the baseline's + * lowest top k score. A baseline returning fewer than + * k hits fails that query, because recall at k is + * undefined. All configurations run against one point in time. + *

+ * The default baseline uses a visit_percentage of 20 and a + * rescore_vector.oversample of 100. An exact full-precision + * baseline must be requested explicitly with allow_exact_baseline, + * and is limited to 100 million vector-by-query comparisons. + *

+ * The request is refused when the search.knn_eval.enabled cluster + * setting or the index.knn_eval.enabled index setting is + * false. + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalRequest extends RequestBase implements JsonpSerializable { + @Nullable + private final Boolean allowExactBaseline; + + @Nullable + private final Boolean allowNoIndices; + + @Nullable + private final KnnEvalSettings baseline; + + private final List expandWildcards; + + private final String field; + + @Nullable + private final Boolean ignoreUnavailable; + + private final List index; + + private final int k; + + private final List knnSettings; + + private final KnnEvalQuerySource querySource; + + @Nullable + private final Boolean waitForCompletion; + + // --------------------------------------------------------------------------------------------- + + private KnnEvalRequest(Builder builder) { + + this.allowExactBaseline = builder.allowExactBaseline; + this.allowNoIndices = builder.allowNoIndices; + this.baseline = builder.baseline; + this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); + this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); + this.ignoreUnavailable = builder.ignoreUnavailable; + this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index"); + this.k = ApiTypeHelper.requireNonNull(builder.k, this, "k", 0); + this.knnSettings = ApiTypeHelper.unmodifiableRequired(builder.knnSettings, this, "knnSettings"); + this.querySource = ApiTypeHelper.requireNonNull(builder.querySource, this, "querySource"); + this.waitForCompletion = builder.waitForCompletion; + + } + + public static KnnEvalRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * If true, the baseline can be exact. An + * exact baseline compares every vector at full precision, and can severely slow + * down other searches. + *

+ * API name: {@code allow_exact_baseline} + */ + @Nullable + public final Boolean allowExactBaseline() { + return this.allowExactBaseline; + } + + /** + * If false, the request returns an error if any wildcard + * expression, index alias, or _all value targets only missing or + * closed indices. This behavior applies even if the request targets other open + * indices. + *

+ * API name: {@code allow_no_indices} + */ + @Nullable + public final Boolean allowNoIndices() { + return this.allowNoIndices; + } + + /** + * The settings of the search that the knn_settings entries are + * compared with. If not specified, it uses a visit_percentage of + * 20 and a rescore_vector.oversample of 100. + *

+ * API name: {@code baseline} + */ + @Nullable + public final KnnEvalSettings baseline() { + return this.baseline; + } + + /** + * The type of index that wildcard patterns can match. It supports + * comma-separated values, such as open,hidden. + *

+ * API name: {@code expand_wildcards} + */ + public final List expandWildcards() { + return this.expandWildcards; + } + + /** + * Required - The dense_vector field to evaluate. + *

+ * API name: {@code field} + */ + public final String field() { + return this.field; + } + + /** + * If false, the request returns an error if it targets a missing + * or closed index. + *

+ * API name: {@code ignore_unavailable} + */ + @Nullable + public final Boolean ignoreUnavailable() { + return this.ignoreUnavailable; + } + + /** + * Required - A comma-separated list of index names to search. + *

+ * API name: {@code index} + */ + public final List index() { + return this.index; + } + + /** + * Required - The number of nearest neighbors to compute the recall for, from 1 + * to 1000. + *

+ * API name: {@code k} + */ + public final int k() { + return this.k; + } + + /** + * Required - The kNN search settings to evaluate, from 1 to 32 unique entries. + *

+ * API name: {@code knn_settings} + */ + public final List knnSettings() { + return this.knnSettings; + } + + /** + * Required - The source of the query vectors. + *

+ * API name: {@code query_source} + */ + public final KnnEvalQuerySource querySource() { + return this.querySource; + } + + /** + * If true, the request waits for the evaluation to complete. A + * large evaluation can run for minutes, and closing the connection, for example + * because of a client or proxy timeout, cancels it. If false, the + * request returns a task identifier, and stores the completed response for + * retrieval through the task management API. + *

+ * API name: {@code wait_for_completion} + */ + @Nullable + public final Boolean waitForCompletion() { + return this.waitForCompletion; + } + + /** + * 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 (this.allowExactBaseline != null) { + generator.writeKey("allow_exact_baseline"); + generator.write(this.allowExactBaseline); + + } + if (this.baseline != null) { + generator.writeKey("baseline"); + this.baseline.serialize(generator, mapper); + + } + generator.writeKey("field"); + generator.write(this.field); + + generator.writeKey("k"); + generator.write(this.k); + + if (ApiTypeHelper.isDefined(this.knnSettings)) { + generator.writeKey("knn_settings"); + generator.writeStartArray(); + for (KnnEvalSettings item0 : this.knnSettings) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("query_source"); + this.querySource.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder implements ObjectBuilder { + @Nullable + private Boolean allowExactBaseline; + + @Nullable + private Boolean allowNoIndices; + + @Nullable + private KnnEvalSettings baseline; + + @Nullable + private List expandWildcards; + + private String field; + + @Nullable + private Boolean ignoreUnavailable; + + private List index; + + private Integer k; + + private List knnSettings; + + private KnnEvalQuerySource querySource; + + @Nullable + private Boolean waitForCompletion; + + public Builder() { + } + private Builder(KnnEvalRequest instance) { + this.allowExactBaseline = instance.allowExactBaseline; + this.allowNoIndices = instance.allowNoIndices; + this.baseline = instance.baseline; + this.expandWildcards = instance.expandWildcards; + this.field = instance.field; + this.ignoreUnavailable = instance.ignoreUnavailable; + this.index = instance.index; + this.k = instance.k; + this.knnSettings = instance.knnSettings; + this.querySource = instance.querySource; + this.waitForCompletion = instance.waitForCompletion; + + } + /** + * If true, the baseline can be exact. An + * exact baseline compares every vector at full precision, and can severely slow + * down other searches. + *

+ * API name: {@code allow_exact_baseline} + */ + public final Builder allowExactBaseline(@Nullable Boolean value) { + this.allowExactBaseline = value; + return this; + } + + /** + * If false, the request returns an error if any wildcard + * expression, index alias, or _all value targets only missing or + * closed indices. This behavior applies even if the request targets other open + * indices. + *

+ * API name: {@code allow_no_indices} + */ + public final Builder allowNoIndices(@Nullable Boolean value) { + this.allowNoIndices = value; + return this; + } + + /** + * The settings of the search that the knn_settings entries are + * compared with. If not specified, it uses a visit_percentage of + * 20 and a rescore_vector.oversample of 100. + *

+ * API name: {@code baseline} + */ + public final Builder baseline(@Nullable KnnEvalSettings value) { + this.baseline = value; + return this; + } + + /** + * The settings of the search that the knn_settings entries are + * compared with. If not specified, it uses a visit_percentage of + * 20 and a rescore_vector.oversample of 100. + *

+ * API name: {@code baseline} + */ + public final Builder baseline(Function> fn) { + return this.baseline(fn.apply(new KnnEvalSettings.Builder()).build()); + } + + /** + * The type of index that wildcard patterns can match. It supports + * comma-separated values, such as open,hidden. + *

+ * API name: {@code expand_wildcards} + *

+ * Adds all elements of list to expandWildcards. + */ + public final Builder expandWildcards(List list) { + this.expandWildcards = _listAddAll(this.expandWildcards, list); + return this; + } + + /** + * The type of index that wildcard patterns can match. It supports + * comma-separated values, such as open,hidden. + *

+ * API name: {@code expand_wildcards} + *

+ * Adds one or more values to expandWildcards. + */ + public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { + this.expandWildcards = _listAdd(this.expandWildcards, value, values); + return this; + } + + /** + * Required - The dense_vector field to evaluate. + *

+ * API name: {@code field} + */ + public final Builder field(String value) { + this.field = value; + return this; + } + + /** + * If false, the request returns an error if it targets a missing + * or closed index. + *

+ * API name: {@code ignore_unavailable} + */ + public final Builder ignoreUnavailable(@Nullable Boolean value) { + this.ignoreUnavailable = value; + return this; + } + + /** + * Required - A comma-separated list of index names to search. + *

+ * API name: {@code index} + *

+ * Adds all elements of list to index. + */ + public final Builder index(List list) { + this.index = _listAddAll(this.index, list); + return this; + } + + /** + * Required - A comma-separated list of index names to search. + *

+ * API name: {@code index} + *

+ * Adds one or more values to index. + */ + public final Builder index(String value, String... values) { + this.index = _listAdd(this.index, value, values); + return this; + } + + /** + * Required - The number of nearest neighbors to compute the recall for, from 1 + * to 1000. + *

+ * API name: {@code k} + */ + public final Builder k(int value) { + this.k = value; + return this; + } + + /** + * Required - The kNN search settings to evaluate, from 1 to 32 unique entries. + *

+ * API name: {@code knn_settings} + *

+ * Adds all elements of list to knnSettings. + */ + public final Builder knnSettings(List list) { + this.knnSettings = _listAddAll(this.knnSettings, list); + return this; + } + + /** + * Required - The kNN search settings to evaluate, from 1 to 32 unique entries. + *

+ * API name: {@code knn_settings} + *

+ * Adds one or more values to knnSettings. + */ + public final Builder knnSettings(KnnEvalSettings value, KnnEvalSettings... values) { + this.knnSettings = _listAdd(this.knnSettings, value, values); + return this; + } + + /** + * Required - The kNN search settings to evaluate, from 1 to 32 unique entries. + *

+ * API name: {@code knn_settings} + *

+ * Adds a value to knnSettings using a builder lambda. + */ + public final Builder knnSettings(Function> fn) { + return knnSettings(fn.apply(new KnnEvalSettings.Builder()).build()); + } + + /** + * Required - The source of the query vectors. + *

+ * API name: {@code query_source} + */ + public final Builder querySource(KnnEvalQuerySource value) { + this.querySource = value; + return this; + } + + /** + * Required - The source of the query vectors. + *

+ * API name: {@code query_source} + */ + public final Builder querySource(Function> fn) { + return this.querySource(fn.apply(new KnnEvalQuerySource.Builder()).build()); + } + + /** + * If true, the request waits for the evaluation to complete. A + * large evaluation can run for minutes, and closing the connection, for example + * because of a client or proxy timeout, cancels it. If false, the + * request returns a task identifier, and stores the completed response for + * retrieval through the task management API. + *

+ * API name: {@code wait_for_completion} + */ + public final Builder waitForCompletion(@Nullable Boolean value) { + this.waitForCompletion = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalRequest build() { + _checkSingleUse(); + + return new KnnEvalRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalRequest} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + KnnEvalRequest::setupKnnEvalRequestDeserializer); + + protected static void setupKnnEvalRequestDeserializer(ObjectDeserializer op) { + + op.add(Builder::allowExactBaseline, JsonpDeserializer.booleanDeserializer(), "allow_exact_baseline"); + op.add(Builder::baseline, KnnEvalSettings._DESERIALIZER, "baseline"); + op.add(Builder::field, JsonpDeserializer.stringDeserializer(), "field"); + op.add(Builder::k, JsonpDeserializer.integerDeserializer(), "k"); + op.add(Builder::knnSettings, JsonpDeserializer.arrayDeserializer(KnnEvalSettings._DESERIALIZER), + "knn_settings"); + op.add(Builder::querySource, KnnEvalQuerySource._DESERIALIZER, "query_source"); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code knn_eval}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/knn_eval", + + // Request method + request -> { + return "POST"; + + }, + + // Request path + request -> { + final int _index = 1 << 0; + + int propsSet = 0; + + propsSet |= _index; + + if (propsSet == (_index)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/_knn_eval"); + return buf.toString(); + } + throw SimpleEndpoint.noPathTemplateFound("path"); + + }, + + // Path parameters + request -> { + Map params = new HashMap<>(); + final int _index = 1 << 0; + + int propsSet = 0; + + propsSet |= _index; + + if (propsSet == (_index)) { + params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } + return params; + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.ignoreUnavailable != null) { + params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); + } + if (ApiTypeHelper.isDefined(request.expandWildcards)) { + params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()) + .filter(Objects::nonNull).collect(Collectors.joining(","))); + } + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); + } + if (request.waitForCompletion != null) { + params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); + } + return params; + + }, SimpleEndpoint.emptyMap(), true, KnnEvalResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/KnnEvalResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/KnnEvalResponse.java new file mode 100644 index 0000000000..87c0528df4 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/KnnEvalResponse.java @@ -0,0 +1,504 @@ +/* + * 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.core; + +import co.elastic.clients.elasticsearch.core.knn_eval.KnnEvalFailure; +import co.elastic.clients.elasticsearch.core.knn_eval.KnnEvalQuerySourceSummary; +import co.elastic.clients.elasticsearch.core.knn_eval.KnnEvalReportedSettings; +import co.elastic.clients.elasticsearch.core.knn_eval.KnnEvalResult; +import co.elastic.clients.elasticsearch.core.knn_eval.KnnEvalVectorOpsKind; +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.JsonpUtils; +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; + +//---------------------------------------------------------------- +// 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: _global.knn_eval.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalResponse implements JsonpSerializable { + @Nullable + private final KnnEvalQuerySourceSummary querySource; + + @Nullable + private final KnnEvalReportedSettings baseline; + + @Nullable + private final Long baselineTookMs; + + @Nullable + private final Long baselineVectorOps; + + @Nullable + private final KnnEvalVectorOpsKind baselineVectorOpsKind; + + private final List results; + + private final Map failures; + + @Nullable + private final String task; + + // --------------------------------------------------------------------------------------------- + + private KnnEvalResponse(Builder builder) { + + this.querySource = builder.querySource; + this.baseline = builder.baseline; + this.baselineTookMs = builder.baselineTookMs; + this.baselineVectorOps = builder.baselineVectorOps; + this.baselineVectorOpsKind = builder.baselineVectorOpsKind; + this.results = ApiTypeHelper.unmodifiable(builder.results); + this.failures = ApiTypeHelper.unmodifiable(builder.failures); + this.task = builder.task; + + } + + public static KnnEvalResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The source of the query vectors. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code query_source} + */ + @Nullable + public final KnnEvalQuerySourceSummary querySource() { + return this.querySource; + } + + /** + * The settings of the baseline search. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code baseline} + */ + @Nullable + public final KnnEvalReportedSettings baseline() { + return this.baseline; + } + + /** + * The time the baseline searches took, in milliseconds. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code baseline_took_ms} + */ + @Nullable + public final Long baselineTookMs() { + return this.baselineTookMs; + } + + /** + * The number of vector operations of the baseline searches. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code baseline_vector_ops} + */ + @Nullable + public final Long baselineVectorOps() { + return this.baselineVectorOps; + } + + /** + * What baseline_vector_ops counts. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code baseline_vector_ops_kind} + */ + @Nullable + public final KnnEvalVectorOpsKind baselineVectorOpsKind() { + return this.baselineVectorOpsKind; + } + + /** + * The results of each knn_settings entry, in the order of the + * request. Not returned when wait_for_completion is + * false. + *

+ * API name: {@code results} + */ + public final List results() { + return this.results; + } + + /** + * The queries that failed, by query identifier. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code failures} + */ + public final Map failures() { + return this.failures; + } + + /** + * The identifier of the task that runs the evaluation. Only returned when + * wait_for_completion is false. + *

+ * API name: {@code task} + */ + @Nullable + public final String task() { + return this.task; + } + + /** + * 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 (this.querySource != null) { + generator.writeKey("query_source"); + this.querySource.serialize(generator, mapper); + + } + if (this.baseline != null) { + generator.writeKey("baseline"); + this.baseline.serialize(generator, mapper); + + } + if (this.baselineTookMs != null) { + generator.writeKey("baseline_took_ms"); + generator.write(this.baselineTookMs); + + } + if (this.baselineVectorOps != null) { + generator.writeKey("baseline_vector_ops"); + generator.write(this.baselineVectorOps); + + } + if (this.baselineVectorOpsKind != null) { + generator.writeKey("baseline_vector_ops_kind"); + this.baselineVectorOpsKind.serialize(generator, mapper); + } + if (ApiTypeHelper.isDefined(this.results)) { + generator.writeKey("results"); + generator.writeStartArray(); + for (KnnEvalResult item0 : this.results) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (ApiTypeHelper.isDefined(this.failures)) { + generator.writeKey("failures"); + generator.writeStartObject(); + for (Map.Entry item0 : this.failures.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (this.task != null) { + generator.writeKey("task"); + generator.write(this.task); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable + private KnnEvalQuerySourceSummary querySource; + + @Nullable + private KnnEvalReportedSettings baseline; + + @Nullable + private Long baselineTookMs; + + @Nullable + private Long baselineVectorOps; + + @Nullable + private KnnEvalVectorOpsKind baselineVectorOpsKind; + + @Nullable + private List results; + + @Nullable + private Map failures; + + @Nullable + private String task; + + /** + * The source of the query vectors. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code query_source} + */ + public final Builder querySource(@Nullable KnnEvalQuerySourceSummary value) { + this.querySource = value; + return this; + } + + /** + * The source of the query vectors. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code query_source} + */ + public final Builder querySource( + Function> fn) { + return this.querySource(fn.apply(new KnnEvalQuerySourceSummary.Builder()).build()); + } + + /** + * The settings of the baseline search. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code baseline} + */ + public final Builder baseline(@Nullable KnnEvalReportedSettings value) { + this.baseline = value; + return this; + } + + /** + * The settings of the baseline search. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code baseline} + */ + public final Builder baseline( + Function> fn) { + return this.baseline(fn.apply(new KnnEvalReportedSettings.Builder()).build()); + } + + /** + * The time the baseline searches took, in milliseconds. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code baseline_took_ms} + */ + public final Builder baselineTookMs(@Nullable Long value) { + this.baselineTookMs = value; + return this; + } + + /** + * The number of vector operations of the baseline searches. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code baseline_vector_ops} + */ + public final Builder baselineVectorOps(@Nullable Long value) { + this.baselineVectorOps = value; + return this; + } + + /** + * What baseline_vector_ops counts. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code baseline_vector_ops_kind} + */ + public final Builder baselineVectorOpsKind(@Nullable KnnEvalVectorOpsKind value) { + this.baselineVectorOpsKind = value; + return this; + } + + /** + * The results of each knn_settings entry, in the order of the + * request. Not returned when wait_for_completion is + * false. + *

+ * API name: {@code results} + *

+ * Adds all elements of list to results. + */ + public final Builder results(List list) { + this.results = _listAddAll(this.results, list); + return this; + } + + /** + * The results of each knn_settings entry, in the order of the + * request. Not returned when wait_for_completion is + * false. + *

+ * API name: {@code results} + *

+ * Adds one or more values to results. + */ + public final Builder results(KnnEvalResult value, KnnEvalResult... values) { + this.results = _listAdd(this.results, value, values); + return this; + } + + /** + * The results of each knn_settings entry, in the order of the + * request. Not returned when wait_for_completion is + * false. + *

+ * API name: {@code results} + *

+ * Adds a value to results using a builder lambda. + */ + public final Builder results(Function> fn) { + return results(fn.apply(new KnnEvalResult.Builder()).build()); + } + + /** + * The queries that failed, by query identifier. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code failures} + *

+ * Adds all entries of map to failures. + */ + public final Builder failures(Map map) { + this.failures = _mapPutAll(this.failures, map); + return this; + } + + /** + * The queries that failed, by query identifier. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code failures} + *

+ * Adds an entry to failures. + */ + public final Builder failures(String key, KnnEvalFailure value) { + this.failures = _mapPut(this.failures, key, value); + return this; + } + + /** + * The queries that failed, by query identifier. Not returned when + * wait_for_completion is false. + *

+ * API name: {@code failures} + *

+ * Adds an entry to failures using a builder lambda. + */ + public final Builder failures(String key, Function> fn) { + return failures(key, fn.apply(new KnnEvalFailure.Builder()).build()); + } + + /** + * The identifier of the task that runs the evaluation. Only returned when + * wait_for_completion is false. + *

+ * API name: {@code task} + */ + public final Builder task(@Nullable String value) { + this.task = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalResponse build() { + _checkSingleUse(); + + return new KnnEvalResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + KnnEvalResponse::setupKnnEvalResponseDeserializer); + + protected static void setupKnnEvalResponseDeserializer(ObjectDeserializer op) { + + op.add(Builder::querySource, KnnEvalQuerySourceSummary._DESERIALIZER, "query_source"); + op.add(Builder::baseline, KnnEvalReportedSettings._DESERIALIZER, "baseline"); + op.add(Builder::baselineTookMs, JsonpDeserializer.longDeserializer(), "baseline_took_ms"); + op.add(Builder::baselineVectorOps, JsonpDeserializer.longDeserializer(), "baseline_vector_ops"); + op.add(Builder::baselineVectorOpsKind, KnnEvalVectorOpsKind._DESERIALIZER, "baseline_vector_ops_kind"); + op.add(Builder::results, JsonpDeserializer.arrayDeserializer(KnnEvalResult._DESERIALIZER), "results"); + op.add(Builder::failures, JsonpDeserializer.stringMapDeserializer(KnnEvalFailure._DESERIALIZER), "failures"); + op.add(Builder::task, JsonpDeserializer.stringDeserializer(), "task"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MgetRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MgetRequest.java index 6ae162dae4..5cbf242887 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MgetRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MgetRequest.java @@ -262,11 +262,9 @@ public final Boolean refresh() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The default slice identifier for a slice-enabled index + * (index.slice.enabled set to true), applied to the + * items that do not specify their own _slice. *

* API name: {@code _slice} */ @@ -597,11 +595,9 @@ public final Builder refresh(@Nullable Boolean value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The default slice identifier for a slice-enabled index + * (index.slice.enabled set to true), applied to the + * items that do not specify their own _slice. *

* API name: {@code _slice} */ @@ -719,11 +715,14 @@ protected static void setupMgetRequestDeserializer(ObjectDeserializer { final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (request.index() != null) propsSet |= _index; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); @@ -737,6 +736,15 @@ protected static void setupMgetRequestDeserializer(ObjectDeserializer { Map params = new HashMap<>(); final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (request.index() != null) propsSet |= _index; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == 0) { } if (propsSet == (_index)) { params.put("index", request.index); } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + } return params; }, @@ -789,9 +804,6 @@ protected static void setupMgetRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) .collect(Collectors.joining(","))); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MsearchRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MsearchRequest.java index e9e626a6c2..811ac4a5a6 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MsearchRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MsearchRequest.java @@ -125,8 +125,7 @@ public class MsearchRequest extends RequestBase implements NdJsonpSerializable, @Nullable private final String projectRouting; - @Nullable - private final String routeSlice; + private final List routeSlice; private final List routing; @@ -150,7 +149,7 @@ private MsearchRequest(Builder builder) { this.maxConcurrentShardRequests = builder.maxConcurrentShardRequests; this.preFilterShardSize = builder.preFilterShardSize; this.projectRouting = builder.projectRouting; - this.routeSlice = builder.routeSlice; + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); this.searchType = builder.searchType; this.searches = ApiTypeHelper.unmodifiableRequired(builder.searches, this, "searches"); @@ -310,16 +309,13 @@ public final String projectRouting() { * The slice identifier for routing the search to a specific slice. When * provided at the top level, all sub-searches are routed to shards matching the * given slice value. Use the special value _all to query all - * slices without restricting to a routing value. Required when - * index.slice.enabled is true for the target index; - * not allowed when index.slice.enabled is false. - * Individual sub-search headers can also specify _slice to - * override the top-level setting. + * slices without restricting to a routing value. When omitted, all slices are + * targeted. Individual sub-search headers can also specify _slice + * to override the top-level setting. *

* API name: {@code _slice} */ - @Nullable - public final String routeSlice() { + public final List routeSlice() { return this.routeSlice; } @@ -406,7 +402,7 @@ public static class Builder extends RequestBase.AbstractBuilder impleme private String projectRouting; @Nullable - private String routeSlice; + private List routeSlice; @Nullable private List routing; @@ -613,16 +609,33 @@ public final Builder projectRouting(@Nullable String value) { * The slice identifier for routing the search to a specific slice. When * provided at the top level, all sub-searches are routed to shards matching the * given slice value. Use the special value _all to query all - * slices without restricting to a routing value. Required when - * index.slice.enabled is true for the target index; - * not allowed when index.slice.enabled is false. - * Individual sub-search headers can also specify _slice to - * override the top-level setting. + * slices without restricting to a routing value. When omitted, all slices are + * targeted. Individual sub-search headers can also specify _slice + * to override the top-level setting. *

* API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. */ - public final Builder routeSlice(@Nullable String value) { - this.routeSlice = value; + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifier for routing the search to a specific slice. When + * provided at the top level, all sub-searches are routed to shards matching the + * given slice value. Use the special value _all to query all + * slices without restricting to a routing value. When omitted, all slices are + * targeted. Individual sub-search headers can also specify _slice + * to override the top-level setting. + *

+ * API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. + */ + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); return this; } @@ -793,8 +806,9 @@ public Builder rebuild() { if (request.projectRouting != null) { params.put("project_routing", request.projectRouting); } - if (request.routeSlice != null) { - params.put("_slice", request.routeSlice); + if (ApiTypeHelper.isDefined(request.routeSlice)) { + params.put("_slice", request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); } if (request.includeNamedQueriesScore != null) { params.put("include_named_queries_score", String.valueOf(request.includeNamedQueriesScore)); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MtermvectorsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MtermvectorsRequest.java index ba723fc936..8314879680 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MtermvectorsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/MtermvectorsRequest.java @@ -253,11 +253,9 @@ public final Boolean realtime() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The default slice identifier for a slice-enabled index + * (index.slice.enabled set to true), applied to the + * items that do not specify their own _slice. *

* API name: {@code _slice} */ @@ -580,11 +578,9 @@ public final Builder realtime(@Nullable Boolean value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The default slice identifier for a slice-enabled index + * (index.slice.enabled set to true), applied to the + * items that do not specify their own _slice. *

* API name: {@code _slice} */ @@ -707,11 +703,14 @@ protected static void setupMtermvectorsRequestDeserializer(ObjectDeserializer { final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (request.index() != null) propsSet |= _index; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); @@ -725,6 +724,15 @@ protected static void setupMtermvectorsRequestDeserializer(ObjectDeserializer { Map params = new HashMap<>(); final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (request.index() != null) propsSet |= _index; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == 0) { } if (propsSet == (_index)) { params.put("index", request.index); } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + } return params; }, // Request parameters request -> { Map params = new HashMap<>(); + if (ApiTypeHelper.isDefined(request.routing)) { + params.put("routing", request.routing.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } if (request.realtime != null) { params.put("realtime", String.valueOf(request.realtime)); } + if (request.termStatistics != null) { + params.put("term_statistics", String.valueOf(request.termStatistics)); + } + if (request.offsets != null) { + params.put("offsets", String.valueOf(request.offsets)); + } if (request.payloads != null) { params.put("payloads", String.valueOf(request.payloads)); } @@ -768,26 +793,13 @@ protected static void setupMtermvectorsRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) - .collect(Collectors.joining(","))); - } - if (request.termStatistics != null) { - params.put("term_statistics", String.valueOf(request.termStatistics)); - } - if (request.offsets != null) { - params.put("offsets", String.valueOf(request.offsets)); - } if (ApiTypeHelper.isDefined(request.fields)) { params.put("fields", request.fields.stream().map(v -> v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (request.version != null) { + params.put("version", String.valueOf(request.version)); + } return params; }, SimpleEndpoint.emptyMap(), true, MtermvectorsResponse._DESERIALIZER); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/OpenPointInTimeRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/OpenPointInTimeRequest.java index 2d8dd1cf67..9604039f2e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/OpenPointInTimeRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/OpenPointInTimeRequest.java @@ -156,6 +156,8 @@ public class OpenPointInTimeRequest extends RequestBase implements JsonpSerializ @Nullable private final String projectRouting; + private final List routeSlice; + private final List routing; // --------------------------------------------------------------------------------------------- @@ -171,6 +173,7 @@ private OpenPointInTimeRequest(Builder builder) { this.maxConcurrentShardRequests = builder.maxConcurrentShardRequests; this.preference = builder.preference; this.projectRouting = builder.projectRouting; + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); } @@ -285,7 +288,21 @@ public final String projectRouting() { } /** - * A custom value that is used to route operations to a specific shard. + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * point in time to that slice. When omitted, the point in time covers all + * slices. + *

+ * API name: {@code _slice} + */ + public final List routeSlice() { + return this.routeSlice; + } + + /** + * A custom value that is used to route operations to a specific shard. Not + * allowed when index.slice.enabled is true for the + * target index; use _slice instead. *

* API name: {@code routing} */ @@ -351,6 +368,9 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private String projectRouting; + @Nullable + private List routeSlice; + @Nullable private List routing; @@ -366,6 +386,7 @@ private Builder(OpenPointInTimeRequest instance) { this.maxConcurrentShardRequests = instance.maxConcurrentShardRequests; this.preference = instance.preference; this.projectRouting = instance.projectRouting; + this.routeSlice = instance.routeSlice; this.routing = instance.routing; } @@ -540,7 +561,39 @@ public final Builder projectRouting(@Nullable String value) { } /** - * A custom value that is used to route operations to a specific shard. + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * point in time to that slice. When omitted, the point in time covers all + * slices. + *

+ * API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. + */ + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * point in time to that slice. When omitted, the point in time covers all + * slices. + *

+ * API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. + */ + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); + return this; + } + + /** + * A custom value that is used to route operations to a specific shard. Not + * allowed when index.slice.enabled is true for the + * target index; use _slice instead. *

* API name: {@code routing} *

@@ -552,7 +605,9 @@ public final Builder routing(List list) { } /** - * A custom value that is used to route operations to a specific shard. + * A custom value that is used to route operations to a specific shard. Not + * allowed when index.slice.enabled is true for the + * target index; use _slice instead. *

* API name: {@code routing} *

@@ -677,6 +732,10 @@ protected static void setupOpenPointInTimeRequestDeserializer( params.put("preference", request.preference); } params.put("keep_alive", request.keepAlive._toJsonString()); + if (ApiTypeHelper.isDefined(request.routeSlice)) { + params.put("_slice", request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } return params; }, SimpleEndpoint.emptyMap(), true, OpenPointInTimeResponse._DESERIALIZER); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/RankEvalRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/RankEvalRequest.java index 0a99799f84..3217be882e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/RankEvalRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/RankEvalRequest.java @@ -25,6 +25,7 @@ import co.elastic.clients.elasticsearch._types.SearchType; import co.elastic.clients.elasticsearch.core.rank_eval.RankEvalMetric; import co.elastic.clients.elasticsearch.core.rank_eval.RankEvalRequestItem; +import co.elastic.clients.elasticsearch.core.rank_eval.RankEvalTemplate; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -92,6 +93,8 @@ public class RankEvalRequest extends RequestBase implements JsonpSerializable { @Nullable private final SearchType searchType; + private final List templates; + // --------------------------------------------------------------------------------------------- private RankEvalRequest(Builder builder) { @@ -103,6 +106,7 @@ private RankEvalRequest(Builder builder) { this.metric = builder.metric; this.requests = ApiTypeHelper.unmodifiableRequired(builder.requests, this, "requests"); this.searchType = builder.searchType; + this.templates = ApiTypeHelper.unmodifiable(builder.templates); } @@ -191,6 +195,17 @@ public final SearchType searchType() { return this.searchType; } + /** + * Query templates that the rated requests can refer to by their + * template_id. This way, queries that differ only in their + * parameters don't have to be repeated in requests. + *

+ * API name: {@code templates} + */ + public final List templates() { + return this.templates; + } + /** * Serialize this object to JSON. */ @@ -217,6 +232,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } + if (ApiTypeHelper.isDefined(this.templates)) { + generator.writeKey("templates"); + generator.writeStartArray(); + for (RankEvalTemplate item0 : this.templates) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } } @@ -247,6 +272,9 @@ public static class Builder extends RequestBase.AbstractBuilder impleme @Nullable private SearchType searchType; + @Nullable + private List templates; + public Builder() { } private Builder(RankEvalRequest instance) { @@ -257,6 +285,7 @@ private Builder(RankEvalRequest instance) { this.metric = instance.metric; this.requests = instance.requests; this.searchType = instance.searchType; + this.templates = instance.templates; } /** @@ -411,6 +440,47 @@ public final Builder searchType(@Nullable SearchType value) { return this; } + /** + * Query templates that the rated requests can refer to by their + * template_id. This way, queries that differ only in their + * parameters don't have to be repeated in requests. + *

+ * API name: {@code templates} + *

+ * Adds all elements of list to templates. + */ + public final Builder templates(List list) { + this.templates = _listAddAll(this.templates, list); + return this; + } + + /** + * Query templates that the rated requests can refer to by their + * template_id. This way, queries that differ only in their + * parameters don't have to be repeated in requests. + *

+ * API name: {@code templates} + *

+ * Adds one or more values to templates. + */ + public final Builder templates(RankEvalTemplate value, RankEvalTemplate... values) { + this.templates = _listAdd(this.templates, value, values); + return this; + } + + /** + * Query templates that the rated requests can refer to by their + * template_id. This way, queries that differ only in their + * parameters don't have to be repeated in requests. + *

+ * API name: {@code templates} + *

+ * Adds a value to templates using a builder lambda. + */ + public final Builder templates(Function> fn) { + return templates(fn.apply(new RankEvalTemplate.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -447,6 +517,7 @@ protected static void setupRankEvalRequestDeserializer(ObjectDeserializer failures; + private final List failures; @Nullable private final Long noops; @@ -184,7 +184,7 @@ public final Long deleted() { *

* API name: {@code failures} */ - public final List failures() { + public final List failures() { return this.failures; } @@ -349,7 +349,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.failures)) { generator.writeKey("failures"); generator.writeStartArray(); - for (BulkIndexByScrollFailure item0 : this.failures) { + for (BulkByPaginatedSearchFailure item0 : this.failures) { item0.serialize(generator, mapper); } @@ -451,7 +451,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Long deleted; @Nullable - private List failures; + private List failures; @Nullable private Long noops; @@ -534,7 +534,7 @@ public final Builder deleted(@Nullable Long value) { *

* Adds all elements of list to failures. */ - public final Builder failures(List list) { + public final Builder failures(List list) { this.failures = _listAddAll(this.failures, list); return this; } @@ -551,7 +551,7 @@ public final Builder failures(List list) { *

* Adds one or more values to failures. */ - public final Builder failures(BulkIndexByScrollFailure value, BulkIndexByScrollFailure... values) { + public final Builder failures(BulkByPaginatedSearchFailure value, BulkByPaginatedSearchFailure... values) { this.failures = _listAdd(this.failures, value, values); return this; } @@ -569,8 +569,8 @@ public final Builder failures(BulkIndexByScrollFailure value, BulkIndexByScrollF * Adds a value to failures using a builder lambda. */ public final Builder failures( - Function> fn) { - return failures(fn.apply(new BulkIndexByScrollFailure.Builder()).build()); + Function> fn) { + return failures(fn.apply(new BulkByPaginatedSearchFailure.Builder()).build()); } /** @@ -771,7 +771,7 @@ protected static void setupReindexResponseDeserializer(ObjectDeserializer routeSlice; private final List routing; @@ -330,7 +329,7 @@ private SearchRequest(Builder builder) { this.requestCache = builder.requestCache; this.rescore = ApiTypeHelper.unmodifiable(builder.rescore); this.retriever = builder.retriever; - this.routeSlice = builder.routeSlice; + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); this.runtimeMappings = ApiTypeHelper.unmodifiable(builder.runtimeMappings); this.scriptFields = ApiTypeHelper.unmodifiable(builder.scriptFields); @@ -869,16 +868,16 @@ public final Retriever retriever() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. *

* API name: {@code _slice} */ - @Nullable - public final String routeSlice() { + public final List routeSlice() { return this.routeSlice; } @@ -1486,7 +1485,7 @@ public static class Builder extends RequestBase.AbstractBuilder impleme private Retriever retriever; @Nullable - private String routeSlice; + private List routeSlice; @Nullable private List routing; @@ -2485,16 +2484,36 @@ public final Builder retriever(RetrieverVariant value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. *

* API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. */ - public final Builder routeSlice(@Nullable String value) { - this.routeSlice = value; + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. + *

+ * API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. + */ + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); return this; } @@ -3069,11 +3088,14 @@ protected static void setupSearchRequestDeserializer(ObjectDeserializer { final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); @@ -3088,6 +3110,17 @@ protected static void setupSearchRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/_search"); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -3096,11 +3129,14 @@ protected static void setupSearchRequestDeserializer(ObjectDeserializer { Map params = new HashMap<>(); final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == 0) { } @@ -3108,6 +3144,12 @@ protected static void setupSearchRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + params.put("routeSlice", request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } return params; }, @@ -3165,9 +3207,6 @@ protected static void setupSearchRequestDeserializer(ObjectDeserializer routeSlice; private final List routing; @@ -111,7 +110,7 @@ private SearchShardsRequest(Builder builder) { this.local = builder.local; this.masterTimeout = builder.masterTimeout; this.preference = builder.preference; - this.routeSlice = builder.routeSlice; + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); } @@ -211,14 +210,11 @@ public final String preference() { * The slice identifier for routing the search to a specific slice. When * provided, the request is limited to shards that match the given slice value. * Use the special value _all to query all slices without - * restricting to a routing value. Required when - * index.slice.enabled is true for the target index; - * not allowed when index.slice.enabled is false. + * restricting to a routing value. When omitted, all slices are targeted. *

* API name: {@code _slice} */ - @Nullable - public final String routeSlice() { + public final List routeSlice() { return this.routeSlice; } @@ -264,7 +260,7 @@ public static class Builder extends RequestBase.AbstractBuilder private String preference; @Nullable - private String routeSlice; + private List routeSlice; @Nullable private List routing; @@ -421,14 +417,29 @@ public final Builder preference(@Nullable String value) { * The slice identifier for routing the search to a specific slice. When * provided, the request is limited to shards that match the given slice value. * Use the special value _all to query all slices without - * restricting to a routing value. Required when - * index.slice.enabled is true for the target index; - * not allowed when index.slice.enabled is false. + * restricting to a routing value. When omitted, all slices are targeted. *

* API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. */ - public final Builder routeSlice(@Nullable String value) { - this.routeSlice = value; + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifier for routing the search to a specific slice. When + * provided, the request is limited to shards that match the given slice value. + * Use the special value _all to query all slices without + * restricting to a routing value. When omitted, all slices are targeted. + *

+ * API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. + */ + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); return this; } @@ -566,8 +577,9 @@ public Builder rebuild() { if (request.preference != null) { params.put("preference", request.preference); } - if (request.routeSlice != null) { - params.put("_slice", request.routeSlice); + if (ApiTypeHelper.isDefined(request.routeSlice)) { + params.put("_slice", request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); } if (request.local != null) { params.put("local", String.valueOf(request.local)); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchTemplateRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchTemplateRequest.java index 80d3f5411d..a505053ddf 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchTemplateRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchTemplateRequest.java @@ -105,6 +105,8 @@ public class SearchTemplateRequest extends RequestBase implements JsonpSerializa @Nullable private final String projectRouting; + private final List routeSlice; + private final List routing; @Nullable @@ -132,6 +134,7 @@ private SearchTemplateRequest(Builder builder) { this.preference = builder.preference; this.profile = builder.profile; this.projectRouting = builder.projectRouting; + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); this.scroll = builder.scroll; this.searchType = builder.searchType; @@ -288,7 +291,23 @@ public final String projectRouting() { } /** - * A custom value used to route operations to a specific shard. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. + *

+ * API name: {@code _slice} + */ + public final List routeSlice() { + return this.routeSlice; + } + + /** + * A custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. *

* API name: {@code routing} */ @@ -424,6 +443,9 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private String projectRouting; + @Nullable + private List routeSlice; + @Nullable private List routing; @@ -451,6 +473,7 @@ private Builder(SearchTemplateRequest instance) { this.preference = instance.preference; this.profile = instance.profile; this.projectRouting = instance.projectRouting; + this.routeSlice = instance.routeSlice; this.routing = instance.routing; this.scroll = instance.scroll; this.searchType = instance.searchType; @@ -652,7 +675,43 @@ public final Builder projectRouting(@Nullable String value) { } /** - * A custom value used to route operations to a specific shard. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. + *

+ * API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. + */ + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. + *

+ * API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. + */ + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); + return this; + } + + /** + * A custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. *

* API name: {@code routing} *

@@ -664,7 +723,9 @@ public final Builder routing(List list) { } /** - * A custom value used to route operations to a specific shard. + * A custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. *

* API name: {@code routing} *

@@ -788,11 +849,14 @@ protected static void setupSearchTemplateRequestDeserializer(ObjectDeserializer< // Request path request -> { final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); @@ -809,6 +873,18 @@ protected static void setupSearchTemplateRequestDeserializer(ObjectDeserializer< buf.append("/template"); return buf.toString(); } + if (propsSet == (_index | _routeSlice)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/_search"); + buf.append("/template"); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -817,11 +893,14 @@ protected static void setupSearchTemplateRequestDeserializer(ObjectDeserializer< request -> { Map params = new HashMap<>(); final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == 0) { } @@ -829,6 +908,12 @@ protected static void setupSearchTemplateRequestDeserializer(ObjectDeserializer< params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + params.put("routeSlice", request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } return params; }, diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/TermvectorsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/TermvectorsRequest.java index 427c288d53..65cba5f934 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/TermvectorsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/TermvectorsRequest.java @@ -341,9 +341,9 @@ public final Boolean realtime() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -755,9 +755,9 @@ public final Builder realtime(@Nullable Boolean value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -921,12 +921,15 @@ protected static void setupTermvectorsRequestDeserializer( request -> { final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; if (request.id() != null) propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { StringBuilder buf = new StringBuilder(); @@ -944,6 +947,26 @@ protected static void setupTermvectorsRequestDeserializer( buf.append("/_termvectors"); return buf.toString(); } + if (propsSet == (_index | _routeSlice | _id)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_termvectors"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.id, buf); + return buf.toString(); + } + if (propsSet == (_index | _routeSlice)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_termvectors"); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -953,12 +976,15 @@ protected static void setupTermvectorsRequestDeserializer( Map params = new HashMap<>(); final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; if (request.id() != null) propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { params.put("index", request.index); @@ -967,6 +993,15 @@ protected static void setupTermvectorsRequestDeserializer( if (propsSet == (_index)) { params.put("index", request.index); } + if (propsSet == (_index | _routeSlice | _id)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + params.put("id", request.id); + } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + } return params; }, @@ -979,9 +1014,6 @@ protected static void setupTermvectorsRequestDeserializer( if (request.preference != null) { params.put("preference", request.preference); } - if (request.routeSlice != null) { - params.put("_slice", request.routeSlice); - } return params; }, SimpleEndpoint.emptyMap(), true, TermvectorsResponse._DESERIALIZER); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateByQueryRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateByQueryRequest.java index 425e758ccf..ec40e12b86 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateByQueryRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateByQueryRequest.java @@ -29,6 +29,7 @@ import co.elastic.clients.elasticsearch._types.Slices; import co.elastic.clients.elasticsearch._types.Time; import co.elastic.clients.elasticsearch._types.WaitForActiveShards; +import co.elastic.clients.elasticsearch._types.mapping.RuntimeField; import co.elastic.clients.elasticsearch._types.query_dsl.Operator; import co.elastic.clients.elasticsearch._types.query_dsl.Query; import co.elastic.clients.elasticsearch._types.query_dsl.QueryVariant; @@ -269,11 +270,12 @@ public class UpdateByQueryRequest extends RequestBase implements JsonpSerializab @Nullable private final Float requestsPerSecond; - @Nullable - private final String routeSlice; + private final List routeSlice; private final List routing; + private final Map runtimeMappings; + @Nullable private final Script script; @@ -340,8 +342,9 @@ private UpdateByQueryRequest(Builder builder) { this.refresh = builder.refresh; this.requestCache = builder.requestCache; this.requestsPerSecond = builder.requestsPerSecond; - this.routeSlice = builder.routeSlice; + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); + this.runtimeMappings = ApiTypeHelper.unmodifiable(builder.runtimeMappings); this.script = builder.script; this.scroll = builder.scroll; this.scrollSize = builder.scrollSize; @@ -589,16 +592,14 @@ public final Float requestsPerSecond() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. *

* API name: {@code _slice} */ - @Nullable - public final String routeSlice() { + public final List routeSlice() { return this.routeSlice; } @@ -613,6 +614,16 @@ public final List routing() { return this.routing; } + /** + * One or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + */ + public final Map runtimeMappings() { + return this.runtimeMappings; + } + /** * The script to run to update the document source or metadata when updating. *

@@ -810,6 +821,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("query"); this.query.serialize(generator, mapper); + } + if (ApiTypeHelper.isDefined(this.runtimeMappings)) { + generator.writeKey("runtime_mappings"); + generator.writeStartObject(); + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + } if (this.script != null) { generator.writeKey("script"); @@ -890,11 +912,14 @@ public static class Builder extends RequestBase.AbstractBuilder private Float requestsPerSecond; @Nullable - private String routeSlice; + private List routeSlice; @Nullable private List routing; + @Nullable + private Map runtimeMappings; + @Nullable private Script script; @@ -964,6 +989,7 @@ private Builder(UpdateByQueryRequest instance) { this.requestsPerSecond = instance.requestsPerSecond; this.routeSlice = instance.routeSlice; this.routing = instance.routing; + this.runtimeMappings = instance.runtimeMappings; this.script = instance.script; this.scroll = instance.scroll; this.scrollSize = instance.scrollSize; @@ -1260,16 +1286,32 @@ public final Builder requestsPerSecond(@Nullable Float value) { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. + *

+ * API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. + */ + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. *

* API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. */ - public final Builder routeSlice(@Nullable String value) { - this.routeSlice = value; + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); return this; } @@ -1301,6 +1343,45 @@ public final Builder routing(String value, String... values) { return this; } + /** + * One or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds all entries of map to runtimeMappings. + */ + public final Builder runtimeMappings(Map map) { + this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); + return this; + } + + /** + * One or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings. + */ + public final Builder runtimeMappings(String key, RuntimeField value) { + this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); + return this; + } + + /** + * One or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * The script to run to update the document source or metadata when updating. *

@@ -1617,6 +1698,8 @@ protected static void setupUpdateByQueryRequestDeserializer(ObjectDeserializer { final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); @@ -1652,6 +1738,17 @@ protected static void setupUpdateByQueryRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/_update_by_query"); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -1660,15 +1757,24 @@ protected static void setupUpdateByQueryRequestDeserializer(ObjectDeserializer { Map params = new HashMap<>(); final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == (_index)) { params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + params.put("routeSlice", request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } return params; }, @@ -1741,9 +1847,6 @@ protected static void setupUpdateByQueryRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) .collect(Collectors.joining(","))); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateByQueryResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateByQueryResponse.java index 84d866ed36..eb25e6a66e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateByQueryResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateByQueryResponse.java @@ -19,7 +19,7 @@ package co.elastic.clients.elasticsearch.core; -import co.elastic.clients.elasticsearch._types.BulkIndexByScrollFailure; +import co.elastic.clients.elasticsearch._types.BulkByPaginatedSearchFailure; import co.elastic.clients.elasticsearch._types.ReindexStatus; import co.elastic.clients.elasticsearch._types.Retries; import co.elastic.clients.elasticsearch._types.Time; @@ -71,7 +71,7 @@ public class UpdateByQueryResponse implements JsonpSerializable { @Nullable private final Long batches; - private final List failures; + private final List failures; @Nullable private final Long noops; @@ -165,7 +165,7 @@ public final Long batches() { *

* API name: {@code failures} */ - public final List failures() { + public final List failures() { return this.failures; } @@ -338,7 +338,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.failures)) { generator.writeKey("failures"); generator.writeStartArray(); - for (BulkIndexByScrollFailure item0 : this.failures) { + for (BulkByPaginatedSearchFailure item0 : this.failures) { item0.serialize(generator, mapper); } @@ -446,7 +446,7 @@ public static class Builder extends WithJsonObjectBuilderBase private Long batches; @Nullable - private List failures; + private List failures; @Nullable private Long noops; @@ -515,7 +515,7 @@ public final Builder batches(@Nullable Long value) { *

* Adds all elements of list to failures. */ - public final Builder failures(List list) { + public final Builder failures(List list) { this.failures = _listAddAll(this.failures, list); return this; } @@ -532,7 +532,7 @@ public final Builder failures(List list) { *

* Adds one or more values to failures. */ - public final Builder failures(BulkIndexByScrollFailure value, BulkIndexByScrollFailure... values) { + public final Builder failures(BulkByPaginatedSearchFailure value, BulkByPaginatedSearchFailure... values) { this.failures = _listAdd(this.failures, value, values); return this; } @@ -550,8 +550,8 @@ public final Builder failures(BulkIndexByScrollFailure value, BulkIndexByScrollF * Adds a value to failures using a builder lambda. */ public final Builder failures( - Function> fn) { - return failures(fn.apply(new BulkIndexByScrollFailure.Builder()).build()); + Function> fn) { + return failures(fn.apply(new BulkByPaginatedSearchFailure.Builder()).build()); } /** @@ -784,7 +784,7 @@ public UpdateByQueryResponse build() { protected static void setupUpdateByQueryResponseDeserializer(ObjectDeserializer op) { op.add(Builder::batches, JsonpDeserializer.longDeserializer(), "batches"); - op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(BulkIndexByScrollFailure._DESERIALIZER), + op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(BulkByPaginatedSearchFailure._DESERIALIZER), "failures"); op.add(Builder::noops, JsonpDeserializer.longDeserializer(), "noops"); op.add(Builder::deleted, JsonpDeserializer.longDeserializer(), "deleted"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateRequest.java index f173ace471..6ad7fa8be6 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/UpdateRequest.java @@ -340,9 +340,9 @@ public final Integer retryOnConflict() { } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -721,9 +721,9 @@ public final Builder retryOnConflict(@Nullable Inte } /** - * The slice identifier used to route the operation to a specific slice. Use the - * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. Required when index.slice.enabled is * true for the target index; not allowed when * index.slice.enabled is false. *

@@ -952,11 +952,14 @@ protected static void setupUpdateRequestDeserializ request -> { final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { StringBuilder buf = new StringBuilder(); @@ -967,6 +970,17 @@ protected static void setupUpdateRequestDeserializ SimpleEndpoint.pathEncode(request.id, buf); return buf.toString(); } + if (propsSet == (_index | _routeSlice | _id)) { + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.routeSlice, buf); + buf.append("/_update"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.id, buf); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -976,16 +990,24 @@ protected static void setupUpdateRequestDeserializ Map params = new HashMap<>(); final int _index = 1 << 0; final int _id = 1 << 1; + final int _routeSlice = 1 << 2; int propsSet = 0; propsSet |= _index; propsSet |= _id; + if (request.routeSlice() != null) + propsSet |= _routeSlice; if (propsSet == (_index | _id)) { params.put("index", request.index); params.put("id", request.id); } + if (propsSet == (_index | _routeSlice | _id)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice); + params.put("id", request.id); + } return params; }, @@ -998,9 +1020,6 @@ protected static void setupUpdateRequestDeserializ if (request.refresh != null) { params.put("refresh", request.refresh.jsonValue()); } - if (request.routeSlice != null) { - params.put("_slice", request.routeSlice); - } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/bulk/BulkOperationBase.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/bulk/BulkOperationBase.java index 6972f3c819..e39e3d956a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/bulk/BulkOperationBase.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/bulk/BulkOperationBase.java @@ -68,6 +68,9 @@ public abstract class BulkOperationBase implements JsonpSerializable { @Nullable private final String routing; + @Nullable + private final String routeSlice; + @Nullable private final Long ifPrimaryTerm; @@ -87,6 +90,7 @@ protected BulkOperationBase(AbstractBuilder builder) { this.id = builder.id; this.index = builder.index; this.routing = builder.routing; + this.routeSlice = builder.routeSlice; this.ifPrimaryTerm = builder.ifPrimaryTerm; this.ifSeqNo = builder.ifSeqNo; this.version = builder.version; @@ -116,7 +120,8 @@ public final String index() { /** * A custom value used to route operations to a specific shard, or multiple - * comma separated values. + * comma separated values. Not allowed when index.slice.enabled is + * true for the target index; use _slice instead. *

* API name: {@code routing} */ @@ -125,6 +130,19 @@ public final String routing() { return this.routing; } + /** + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. It overrides the _slice set in the + * request path. + *

+ * API name: {@code _slice} + */ + @Nullable + public final String routeSlice() { + return this.routeSlice; + } + /** * API name: {@code if_primary_term} */ @@ -182,6 +200,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("routing"); generator.write(this.routing); + } + if (this.routeSlice != null) { + generator.writeKey("_slice"); + generator.write(this.routeSlice); + } if (this.ifPrimaryTerm != null) { generator.writeKey("if_primary_term"); @@ -222,6 +245,9 @@ public abstract static class AbstractBuilderindex.slice.enabled is + * true for the target index; use _slice instead. *

* API name: {@code routing} */ @@ -265,6 +292,19 @@ public final BuilderT routing(@Nullable String value) { return self(); } + /** + * The slice identifier for a slice-enabled index + * (index.slice.enabled set to true), which scopes the + * operation to that slice. It overrides the _slice set in the + * request path. + *

+ * API name: {@code _slice} + */ + public final BuilderT routeSlice(@Nullable String value) { + this.routeSlice = value; + return self(); + } + /** * API name: {@code if_primary_term} */ @@ -308,6 +348,7 @@ protected static > void setupBulkOper op.add(AbstractBuilder::id, JsonpDeserializer.stringDeserializer(), "_id"); op.add(AbstractBuilder::index, JsonpDeserializer.stringDeserializer(), "_index"); op.add(AbstractBuilder::routing, JsonpDeserializer.stringDeserializer(), "routing"); + op.add(AbstractBuilder::routeSlice, JsonpDeserializer.stringDeserializer(), "_slice"); op.add(AbstractBuilder::ifPrimaryTerm, JsonpDeserializer.longDeserializer(), "if_primary_term"); op.add(AbstractBuilder::ifSeqNo, JsonpDeserializer.longDeserializer(), "if_seq_no"); op.add(AbstractBuilder::version, JsonpDeserializer.longDeserializer(), "version"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/field_caps/FieldCapability.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/field_caps/FieldCapability.java index 2755e6bb04..a3298d7648 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/field_caps/FieldCapability.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/field_caps/FieldCapability.java @@ -84,6 +84,11 @@ public class FieldCapability implements JsonpSerializable { private final List nonInferenceIndices; + @Nullable + private final Boolean passthrough; + + private final List nonPassthroughIndices; + @Nullable private final Boolean metadataField; @@ -110,6 +115,8 @@ private FieldCapability(Builder builder) { this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); this.inference = builder.inference; this.nonInferenceIndices = ApiTypeHelper.unmodifiable(builder.nonInferenceIndices); + this.passthrough = builder.passthrough; + this.nonPassthroughIndices = ApiTypeHelper.unmodifiable(builder.nonPassthroughIndices); this.metadataField = builder.metadataField; this.timeSeriesDimension = builder.timeSeriesDimension; this.timeSeriesMetric = builder.timeSeriesMetric; @@ -211,6 +218,27 @@ public final List nonInferenceIndices() { return this.nonInferenceIndices; } + /** + * Whether this field is a passthrough source on all indices. This property is + * present only for field types that support passthrough. + *

+ * API name: {@code passthrough} + */ + @Nullable + public final Boolean passthrough() { + return this.passthrough; + } + + /** + * The list of indices where this field is not a passthrough source, or null if + * all indices have the same definition for the field. + *

+ * API name: {@code non_passthrough_indices} + */ + public final List nonPassthroughIndices() { + return this.nonPassthroughIndices; + } + /** * Whether this field is registered as a metadata field. *

@@ -337,6 +365,21 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } generator.writeEnd(); + } + if (this.passthrough != null) { + generator.writeKey("passthrough"); + generator.write(this.passthrough); + + } + if (ApiTypeHelper.isDefined(this.nonPassthroughIndices)) { + generator.writeKey("non_passthrough_indices"); + generator.writeStartArray(); + for (String item0 : this.nonPassthroughIndices) { + generator.write(item0); + + } + generator.writeEnd(); + } if (this.metadataField != null) { generator.writeKey("metadata_field"); @@ -411,6 +454,12 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private List nonInferenceIndices; + @Nullable + private Boolean passthrough; + + @Nullable + private List nonPassthroughIndices; + @Nullable private Boolean metadataField; @@ -438,6 +487,8 @@ private Builder(FieldCapability instance) { this.type = instance.type; this.inference = instance.inference; this.nonInferenceIndices = instance.nonInferenceIndices; + this.passthrough = instance.passthrough; + this.nonPassthroughIndices = instance.nonPassthroughIndices; this.metadataField = instance.metadataField; this.timeSeriesDimension = instance.timeSeriesDimension; this.timeSeriesMetric = instance.timeSeriesMetric; @@ -620,6 +671,43 @@ public final Builder nonInferenceIndices(String value, String... values) { return this; } + /** + * Whether this field is a passthrough source on all indices. This property is + * present only for field types that support passthrough. + *

+ * API name: {@code passthrough} + */ + public final Builder passthrough(@Nullable Boolean value) { + this.passthrough = value; + return this; + } + + /** + * The list of indices where this field is not a passthrough source, or null if + * all indices have the same definition for the field. + *

+ * API name: {@code non_passthrough_indices} + *

+ * Adds all elements of list to nonPassthroughIndices. + */ + public final Builder nonPassthroughIndices(List list) { + this.nonPassthroughIndices = _listAddAll(this.nonPassthroughIndices, list); + return this; + } + + /** + * The list of indices where this field is not a passthrough source, or null if + * all indices have the same definition for the field. + *

+ * API name: {@code non_passthrough_indices} + *

+ * Adds one or more values to nonPassthroughIndices. + */ + public final Builder nonPassthroughIndices(String value, String... values) { + this.nonPassthroughIndices = _listAdd(this.nonPassthroughIndices, value, values); + return this; + } + /** * Whether this field is registered as a metadata field. *

@@ -752,6 +840,9 @@ protected static void setupFieldCapabilityDeserializer(ObjectDeserializer implements JsonpSerializable { @Nullable private final String routing; + @Nullable + private final String slice; + @Nullable private final Long seqNo; @@ -106,6 +109,7 @@ protected GetResult(AbstractBuilder builder) { this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); this.primaryTerm = builder.primaryTerm; this.routing = builder.routing; + this.slice = builder.slice; this.seqNo = builder.seqNo; this.source = builder.source; this.version = builder.version; @@ -183,6 +187,17 @@ public final String routing() { return this.routing; } + /** + * The slice the document belongs to, for a slice-enabled index + * (index.slice.enabled set to true). + *

+ * API name: {@code _slice} + */ + @Nullable + public final String slice() { + return this.slice; + } + /** * The sequence number assigned to the document for the indexing operation. * Sequence numbers are used to ensure an older version of a document doesn't @@ -268,6 +283,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("_routing"); generator.write(this.routing); + } + if (this.slice != null) { + generator.writeKey("_slice"); + generator.write(this.slice); + } if (this.seqNo != null) { generator.writeKey("_seq_no"); @@ -340,6 +360,9 @@ public abstract static class AbstractBuilderindex.slice.enabled set to true). + *

+ * API name: {@code _slice} + */ + public final BuilderT slice(@Nullable String value) { + this.slice = value; + return self(); + } + /** * The sequence number assigned to the document for the indexing operation. * Sequence numbers are used to ensure an older version of a document doesn't @@ -528,6 +562,7 @@ protected static + * API name: {@code index_name} */ public final String indexName() { return this.indexName; } /** - * Required - API name: {@code transition_state} + * Required - The transition state of the overdue index. + *

+ * API name: {@code transition_state} */ public final DlmFrozenTransitionState transitionState() { return this.transitionState; @@ -137,7 +141,9 @@ private Builder(DlmFrozenTransitionOverdueIndex instance) { } /** - * Required - API name: {@code index_name} + * Required - The name of the overdue index. + *

+ * API name: {@code index_name} */ public final Builder indexName(String value) { this.indexName = value; @@ -145,7 +151,9 @@ public final Builder indexName(String value) { } /** - * Required - API name: {@code transition_state} + * Required - The transition state of the overdue index. + *

+ * API name: {@code transition_state} */ public final Builder transitionState(DlmFrozenTransitionState value) { this.transitionState = value; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionState.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionState.java index 82c0d95416..3d997a31a6 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionState.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionState.java @@ -46,12 +46,27 @@ */ @JsonpDeserializable public enum DlmFrozenTransitionState implements JsonEnum { + /** + * The index is eligible for a frozen-tier transition but the data stream + * lifecycle has not marked it for conversion. + */ Unmarked("unmarked"), + /** + * The index is marked for conversion but has not been submitted to the + * transition executor. + */ Marked("marked"), + /** + * The index has been submitted to the transition executor and is waiting in its + * queue for a thread. + */ Queued("queued"), + /** + * The transition of the index is in progress. + */ Running("running"), ; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionsIndicatorDetails.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionsIndicatorDetails.java index 02034db73b..344192c145 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionsIndicatorDetails.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionsIndicatorDetails.java @@ -57,7 +57,11 @@ // typedef: _global.health_report.DlmFrozenTransitionsIndicatorDetails /** - * + * An index is overdue when it has passed its frozen_after age by + * more than the configured threshold and has not yet completed its transition + * to the frozen tier. Indices with a running transition are making progress and + * are not counted as overdue. + * * @see API * specification @@ -103,6 +107,9 @@ public static DlmFrozenTransitionsIndicatorDetails of( } /** + * Indicates whether frozen-tier transitions are enabled by the + * dlm.frozen_transitions.enabled cluster setting. + *

* API name: {@code transitions_enabled} */ @Nullable @@ -111,6 +118,9 @@ public final Boolean transitionsEnabled() { } /** + * Indicates whether the frozen transition service is running on the current + * master node. + *

* API name: {@code service_running} */ @Nullable @@ -119,6 +129,9 @@ public final Boolean serviceRunning() { } /** + * Indicates whether a default snapshot repository is configured with the + * repositories.default_repository cluster setting. + *

* API name: {@code default_repository_configured} */ @Nullable @@ -127,6 +140,8 @@ public final Boolean defaultRepositoryConfigured() { } /** + * The total number of overdue indices in the cluster. + *

* API name: {@code overdue_indices_count} */ @Nullable @@ -135,6 +150,9 @@ public final Integer overdueIndicesCount() { } /** + * The number of overdue indices in the cluster for each transition state. Only + * present when there are overdue indices. + *

* API name: {@code overdue_indices_count_by_state} */ public final Map overdueIndicesCountByState() { @@ -142,6 +160,11 @@ public final Map overdueIndicesCountByState() } /** + * A sample of the overdue indices and their transition states, sorted by index + * name. The sample is limited to 100 indices for each transition state, so it + * can contain fewer indices than overdue_indices_count. Only + * present when there are overdue indices. + *

* API name: {@code overdue_indices_sample} */ public final List overdueIndicesSample() { @@ -149,8 +172,9 @@ public final List overdueIndicesSample() { } /** - * Only present when the indicator status is unknown, meaning the - * health snapshot is stale. + * The time, in milliseconds since the Unix epoch, when the master node + * generated the health snapshot. Only present when the indicator status is + * unknown, meaning the health snapshot is stale. *

* API name: {@code generated_at_millis} */ @@ -267,6 +291,9 @@ private Builder(DlmFrozenTransitionsIndicatorDetails instance) { } /** + * Indicates whether frozen-tier transitions are enabled by the + * dlm.frozen_transitions.enabled cluster setting. + *

* API name: {@code transitions_enabled} */ public final Builder transitionsEnabled(@Nullable Boolean value) { @@ -275,6 +302,9 @@ public final Builder transitionsEnabled(@Nullable Boolean value) { } /** + * Indicates whether the frozen transition service is running on the current + * master node. + *

* API name: {@code service_running} */ public final Builder serviceRunning(@Nullable Boolean value) { @@ -283,6 +313,9 @@ public final Builder serviceRunning(@Nullable Boolean value) { } /** + * Indicates whether a default snapshot repository is configured with the + * repositories.default_repository cluster setting. + *

* API name: {@code default_repository_configured} */ public final Builder defaultRepositoryConfigured(@Nullable Boolean value) { @@ -291,6 +324,8 @@ public final Builder defaultRepositoryConfigured(@Nullable Boolean value) { } /** + * The total number of overdue indices in the cluster. + *

* API name: {@code overdue_indices_count} */ public final Builder overdueIndicesCount(@Nullable Integer value) { @@ -299,6 +334,9 @@ public final Builder overdueIndicesCount(@Nullable Integer value) { } /** + * The number of overdue indices in the cluster for each transition state. Only + * present when there are overdue indices. + *

* API name: {@code overdue_indices_count_by_state} *

* Adds all entries of map to @@ -310,6 +348,9 @@ public final Builder overdueIndicesCountByState(Map * API name: {@code overdue_indices_count_by_state} *

* Adds an entry to overdueIndicesCountByState. @@ -320,6 +361,11 @@ public final Builder overdueIndicesCountByState(DlmFrozenTransitionState key, In } /** + * A sample of the overdue indices and their transition states, sorted by index + * name. The sample is limited to 100 indices for each transition state, so it + * can contain fewer indices than overdue_indices_count. Only + * present when there are overdue indices. + *

* API name: {@code overdue_indices_sample} *

* Adds all elements of list to overdueIndicesSample. @@ -330,6 +376,11 @@ public final Builder overdueIndicesSample(List } /** + * A sample of the overdue indices and their transition states, sorted by index + * name. The sample is limited to 100 indices for each transition state, so it + * can contain fewer indices than overdue_indices_count. Only + * present when there are overdue indices. + *

* API name: {@code overdue_indices_sample} *

* Adds one or more values to overdueIndicesSample. @@ -341,6 +392,11 @@ public final Builder overdueIndicesSample(DlmFrozenTransitionOverdueIndex value, } /** + * A sample of the overdue indices and their transition states, sorted by index + * name. The sample is limited to 100 indices for each transition state, so it + * can contain fewer indices than overdue_indices_count. Only + * present when there are overdue indices. + *

* API name: {@code overdue_indices_sample} *

* Adds a value to overdueIndicesSample using a builder lambda. @@ -351,8 +407,9 @@ public final Builder overdueIndicesSample( } /** - * Only present when the indicator status is unknown, meaning the - * health snapshot is stale. + * The time, in milliseconds since the Unix epoch, when the master node + * generated the health snapshot. Only present when the indicator status is + * unknown, meaning the health snapshot is stale. *

* API name: {@code generated_at_millis} */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/Indicators.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/Indicators.java index 7b73fba211..aae0c67762 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/Indicators.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/Indicators.java @@ -86,7 +86,7 @@ public class Indicators implements JsonpSerializable { private final FileSettingsIndicator fileSettings; @Nullable - private final ProjectEncryptionKeyIndicator projectEncryptionKey; + private final ProjectEncryptionKeyIndicator clusterStateEncryption; @Nullable private final DlmFrozenTransitionsIndicator dlmFrozenTransitions; @@ -104,7 +104,7 @@ private Indicators(Builder builder) { this.slm = builder.slm; this.shardsCapacity = builder.shardsCapacity; this.fileSettings = builder.fileSettings; - this.projectEncryptionKey = builder.projectEncryptionKey; + this.clusterStateEncryption = builder.clusterStateEncryption; this.dlmFrozenTransitions = builder.dlmFrozenTransitions; } @@ -186,14 +186,17 @@ public final FileSettingsIndicator fileSettings() { } /** - * API name: {@code project_encryption_key} + * API name: {@code cluster_state_encryption} */ @Nullable - public final ProjectEncryptionKeyIndicator projectEncryptionKey() { - return this.projectEncryptionKey; + public final ProjectEncryptionKeyIndicator clusterStateEncryption() { + return this.clusterStateEncryption; } /** + * Reports the health of data stream lifecycle transitions of backing indices to + * the frozen tier. + *

* API name: {@code dlm_frozen_transitions} */ @Nullable @@ -257,9 +260,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.fileSettings.serialize(generator, mapper); } - if (this.projectEncryptionKey != null) { - generator.writeKey("project_encryption_key"); - this.projectEncryptionKey.serialize(generator, mapper); + if (this.clusterStateEncryption != null) { + generator.writeKey("cluster_state_encryption"); + this.clusterStateEncryption.serialize(generator, mapper); } if (this.dlmFrozenTransitions != null) { @@ -310,7 +313,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private FileSettingsIndicator fileSettings; @Nullable - private ProjectEncryptionKeyIndicator projectEncryptionKey; + private ProjectEncryptionKeyIndicator clusterStateEncryption; @Nullable private DlmFrozenTransitionsIndicator dlmFrozenTransitions; @@ -327,7 +330,7 @@ private Builder(Indicators instance) { this.slm = instance.slm; this.shardsCapacity = instance.shardsCapacity; this.fileSettings = instance.fileSettings; - this.projectEncryptionKey = instance.projectEncryptionKey; + this.clusterStateEncryption = instance.clusterStateEncryption; this.dlmFrozenTransitions = instance.dlmFrozenTransitions; } @@ -473,22 +476,25 @@ public final Builder fileSettings( } /** - * API name: {@code project_encryption_key} + * API name: {@code cluster_state_encryption} */ - public final Builder projectEncryptionKey(@Nullable ProjectEncryptionKeyIndicator value) { - this.projectEncryptionKey = value; + public final Builder clusterStateEncryption(@Nullable ProjectEncryptionKeyIndicator value) { + this.clusterStateEncryption = value; return this; } /** - * API name: {@code project_encryption_key} + * API name: {@code cluster_state_encryption} */ - public final Builder projectEncryptionKey( + public final Builder clusterStateEncryption( Function> fn) { - return this.projectEncryptionKey(fn.apply(new ProjectEncryptionKeyIndicator.Builder()).build()); + return this.clusterStateEncryption(fn.apply(new ProjectEncryptionKeyIndicator.Builder()).build()); } /** + * Reports the health of data stream lifecycle transitions of backing indices to + * the frozen tier. + *

* API name: {@code dlm_frozen_transitions} */ public final Builder dlmFrozenTransitions(@Nullable DlmFrozenTransitionsIndicator value) { @@ -497,6 +503,9 @@ public final Builder dlmFrozenTransitions(@Nullable DlmFrozenTransitionsIndicato } /** + * Reports the health of data stream lifecycle transitions of backing indices to + * the frozen tier. + *

* API name: {@code dlm_frozen_transitions} */ public final Builder dlmFrozenTransitions( @@ -547,7 +556,8 @@ protected static void setupIndicatorsDeserializer(ObjectDeserializerAPI + * specification + */ +@JsonpDeserializable +public class KnnEvalDocsQuerySource implements KnnEvalQuerySourceVariant, JsonpSerializable { + private final int size; + + @Nullable + private final Integer seed; + + // --------------------------------------------------------------------------------------------- + + private KnnEvalDocsQuerySource(Builder builder) { + + this.size = ApiTypeHelper.requireNonNull(builder.size, this, "size", 0); + this.seed = builder.seed; + + } + + public static KnnEvalDocsQuerySource of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * KnnEvalQuerySource variant kind. + */ + @Override + public KnnEvalQuerySource.Kind _knnEvalQuerySourceKind() { + return KnnEvalQuerySource.Kind.Docs; + } + + /** + * Required - The number of documents to sample, from 1 to 1000. + *

+ * API name: {@code size} + */ + public final int size() { + return this.size; + } + + /** + * The seed of the sampling, to sample the same documents across requests. + *

+ * API name: {@code seed} + */ + @Nullable + public final Integer seed() { + return this.seed; + } + + /** + * 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.write("from", "docs"); + + generator.writeKey("size"); + generator.write(this.size); + + if (this.seed != null) { + generator.writeKey("seed"); + generator.write(this.seed); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalDocsQuerySource}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Integer size; + + @Nullable + private Integer seed; + + public Builder() { + } + private Builder(KnnEvalDocsQuerySource instance) { + this.size = instance.size; + this.seed = instance.seed; + + } + /** + * Required - The number of documents to sample, from 1 to 1000. + *

+ * API name: {@code size} + */ + public final Builder size(int value) { + this.size = value; + return this; + } + + /** + * The seed of the sampling, to sample the same documents across requests. + *

+ * API name: {@code seed} + */ + public final Builder seed(@Nullable Integer value) { + this.seed = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalDocsQuerySource}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalDocsQuerySource build() { + _checkSingleUse(); + + return new KnnEvalDocsQuerySource(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalDocsQuerySource} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, KnnEvalDocsQuerySource::setupKnnEvalDocsQuerySourceDeserializer); + + protected static void setupKnnEvalDocsQuerySourceDeserializer( + ObjectDeserializer op) { + + op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); + op.add(Builder::seed, JsonpDeserializer.integerDeserializer(), "seed"); + + op.ignore("from"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalFailure.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalFailure.java new file mode 100644 index 0000000000..5d490cdf27 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalFailure.java @@ -0,0 +1,173 @@ +/* + * 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.core.knn_eval; + +import co.elastic.clients.elasticsearch._types.ErrorCause; +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.JsonpUtils; +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.util.Objects; +import java.util.function.Function; +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: _global.knn_eval.KnnEvalFailure + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalFailure implements JsonpSerializable { + private final ErrorCause error; + + // --------------------------------------------------------------------------------------------- + + private KnnEvalFailure(Builder builder) { + + this.error = ApiTypeHelper.requireNonNull(builder.error, this, "error"); + + } + + public static KnnEvalFailure of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code error} + */ + public final ErrorCause error() { + return this.error; + } + + /** + * 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("error"); + this.error.serialize(generator, mapper); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalFailure}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private ErrorCause error; + + public Builder() { + } + private Builder(KnnEvalFailure instance) { + this.error = instance.error; + + } + /** + * Required - API name: {@code error} + */ + public final Builder error(ErrorCause value) { + this.error = value; + return this; + } + + /** + * Required - API name: {@code error} + */ + public final Builder error(Function> fn) { + return this.error(fn.apply(new ErrorCause.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalFailure}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalFailure build() { + _checkSingleUse(); + + return new KnnEvalFailure(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalFailure} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + KnnEvalFailure::setupKnnEvalFailureDeserializer); + + protected static void setupKnnEvalFailureDeserializer(ObjectDeserializer op) { + + op.add(Builder::error, ErrorCause._DESERIALIZER, "error"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySource.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySource.java new file mode 100644 index 0000000000..a519f63f4d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySource.java @@ -0,0 +1,224 @@ +/* + * 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.core.knn_eval; + +import co.elastic.clients.json.JsonEnum; +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.JsonpUtils; +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.TaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +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: _global.knn_eval.KnnEvalQuerySource + +/** + * The source of the query vectors of a kNN evaluation. + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalQuerySource + implements + TaggedUnion, + JsonpSerializable { + + /** + * {@link KnnEvalQuerySource} variant kinds. + * + * @see API + * specification + */ + + public enum Kind implements JsonEnum { + Docs("docs"), + + Vectors("vectors"), + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final KnnEvalQuerySourceVariant _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final KnnEvalQuerySourceVariant _get() { + return _value; + } + + public KnnEvalQuerySource(KnnEvalQuerySourceVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._knnEvalQuerySourceKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + + } + + private KnnEvalQuerySource(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static KnnEvalQuerySource of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code docs}? + */ + public boolean isDocs() { + return _kind == Kind.Docs; + } + + /** + * Get the {@code docs} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code docs} kind. + */ + public KnnEvalDocsQuerySource docs() { + return TaggedUnionUtils.get(this, Kind.Docs); + } + + /** + * Is this variant instance of kind {@code vectors}? + */ + public boolean isVectors() { + return _kind == Kind.Vectors; + } + + /** + * Get the {@code vectors} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code vectors} kind. + */ + public KnnEvalVectorsQuerySource vectors() { + return TaggedUnionUtils.get(this, Kind.Vectors); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + + mapper.serialize(_value, generator); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Kind _kind; + private KnnEvalQuerySourceVariant _value; + + @Override + protected Builder self() { + return this; + } + public ObjectBuilder docs(KnnEvalDocsQuerySource v) { + this._kind = Kind.Docs; + this._value = v; + return this; + } + + public ObjectBuilder docs( + Function> fn) { + return this.docs(fn.apply(new KnnEvalDocsQuerySource.Builder()).build()); + } + + public ObjectBuilder vectors(KnnEvalVectorsQuerySource v) { + this._kind = Kind.Vectors; + this._value = v; + return this; + } + + public ObjectBuilder vectors( + Function> fn) { + return this.vectors(fn.apply(new KnnEvalVectorsQuerySource.Builder()).build()); + } + + public KnnEvalQuerySource build() { + _checkSingleUse(); + return new KnnEvalQuerySource(this); + } + + } + + protected static void setupKnnEvalQuerySourceDeserializer(ObjectDeserializer op) { + + op.add(Builder::docs, KnnEvalDocsQuerySource._DESERIALIZER, "docs"); + op.add(Builder::vectors, KnnEvalVectorsQuerySource._DESERIALIZER, "vectors"); + + op.setTypeProperty("from", null); + + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, KnnEvalQuerySource::setupKnnEvalQuerySourceDeserializer, Builder::build); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceBuilders.java new file mode 100644 index 0000000000..37239cec59 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceBuilders.java @@ -0,0 +1,85 @@ +/* + * 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.core.knn_eval; + +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link KnnEvalQuerySource} variants. + */ +public class KnnEvalQuerySourceBuilders { + private KnnEvalQuerySourceBuilders() { + } + + /** + * Creates a builder for the {@link KnnEvalDocsQuerySource docs} + * {@code KnnEvalQuerySource} variant. + */ + public static KnnEvalDocsQuerySource.Builder docs() { + return new KnnEvalDocsQuerySource.Builder(); + } + + /** + * Creates a KnnEvalQuerySource of the {@link KnnEvalDocsQuerySource docs} + * {@code KnnEvalQuerySource} variant. + */ + public static KnnEvalQuerySource docs( + Function> fn) { + KnnEvalQuerySource.Builder builder = new KnnEvalQuerySource.Builder(); + builder.docs(fn.apply(new KnnEvalDocsQuerySource.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link KnnEvalVectorsQuerySource vectors} + * {@code KnnEvalQuerySource} variant. + */ + public static KnnEvalVectorsQuerySource.Builder vectors() { + return new KnnEvalVectorsQuerySource.Builder(); + } + + /** + * Creates a KnnEvalQuerySource of the {@link KnnEvalVectorsQuerySource vectors} + * {@code KnnEvalQuerySource} variant. + */ + public static KnnEvalQuerySource vectors( + Function> fn) { + KnnEvalQuerySource.Builder builder = new KnnEvalQuerySource.Builder(); + builder.vectors(fn.apply(new KnnEvalVectorsQuerySource.Builder()).build()); + return builder.build(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceSummary.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceSummary.java new file mode 100644 index 0000000000..3305ad2f5c --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceSummary.java @@ -0,0 +1,172 @@ +/* + * 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.core.knn_eval; + +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.JsonpUtils; +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.util.Objects; +import java.util.function.Function; +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: _global.knn_eval.KnnEvalQuerySourceSummary + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalQuerySourceSummary implements JsonpSerializable { + private final KnnEvalQuerySourceType from; + + // --------------------------------------------------------------------------------------------- + + private KnnEvalQuerySourceSummary(Builder builder) { + + this.from = ApiTypeHelper.requireNonNull(builder.from, this, "from"); + + } + + public static KnnEvalQuerySourceSummary of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - How the query vectors were chosen. + *

+ * API name: {@code from} + */ + public final KnnEvalQuerySourceType from() { + return this.from; + } + + /** + * 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("from"); + this.from.serialize(generator, mapper); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalQuerySourceSummary}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private KnnEvalQuerySourceType from; + + public Builder() { + } + private Builder(KnnEvalQuerySourceSummary instance) { + this.from = instance.from; + + } + /** + * Required - How the query vectors were chosen. + *

+ * API name: {@code from} + */ + public final Builder from(KnnEvalQuerySourceType value) { + this.from = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalQuerySourceSummary}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalQuerySourceSummary build() { + _checkSingleUse(); + + return new KnnEvalQuerySourceSummary(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalQuerySourceSummary} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, KnnEvalQuerySourceSummary::setupKnnEvalQuerySourceSummaryDeserializer); + + protected static void setupKnnEvalQuerySourceSummaryDeserializer( + ObjectDeserializer op) { + + op.add(Builder::from, KnnEvalQuerySourceType._DESERIALIZER, "from"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceType.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceType.java new file mode 100644 index 0000000000..b36d82fc3b --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceType.java @@ -0,0 +1,67 @@ +/* + * 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.core.knn_eval; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum KnnEvalQuerySourceType implements JsonEnum { + Docs("docs"), + + Vectors("vectors"), + + ; + + private final String jsonValue; + + KnnEvalQuerySourceType(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + KnnEvalQuerySourceType.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceVariant.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceVariant.java new file mode 100644 index 0000000000..3c88eef30b --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQuerySourceVariant.java @@ -0,0 +1,50 @@ +/* + * 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.core.knn_eval; + +import co.elastic.clients.json.JsonpSerializable; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Base interface for {@link KnnEvalQuerySource} variants. + */ +public interface KnnEvalQuerySourceVariant extends JsonpSerializable { + + KnnEvalQuerySource.Kind _knnEvalQuerySourceKind(); + + default KnnEvalQuerySource _toKnnEvalQuerySource() { + return new KnnEvalQuerySource(this); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQueryVector.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQueryVector.java new file mode 100644 index 0000000000..c2da50a40a --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalQueryVector.java @@ -0,0 +1,228 @@ +/* + * 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.core.knn_eval; + +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.JsonpUtils; +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.Float; +import java.lang.String; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: _global.knn_eval.KnnEvalQueryVector + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalQueryVector implements JsonpSerializable { + private final String id; + + private final List queryVector; + + // --------------------------------------------------------------------------------------------- + + private KnnEvalQueryVector(Builder builder) { + + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.queryVector = ApiTypeHelper.unmodifiableRequired(builder.queryVector, this, "queryVector"); + + } + + public static KnnEvalQueryVector of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The identifier of the query, which identifies it in the + * failures of the response. + *

+ * API name: {@code id} + */ + public final String id() { + return this.id; + } + + /** + * Required - The query vector. + *

+ * API name: {@code query_vector} + */ + public final List queryVector() { + return this.queryVector; + } + + /** + * 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("id"); + generator.write(this.id); + + if (ApiTypeHelper.isDefined(this.queryVector)) { + generator.writeKey("query_vector"); + generator.writeStartArray(); + for (Float item0 : this.queryVector) { + generator.write(item0); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalQueryVector}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String id; + + private List queryVector; + + public Builder() { + } + private Builder(KnnEvalQueryVector instance) { + this.id = instance.id; + this.queryVector = instance.queryVector; + + } + /** + * Required - The identifier of the query, which identifies it in the + * failures of the response. + *

+ * API name: {@code id} + */ + public final Builder id(String value) { + this.id = value; + return this; + } + + /** + * Required - The query vector. + *

+ * API name: {@code query_vector} + *

+ * Adds all elements of list to queryVector. + */ + public final Builder queryVector(List list) { + this.queryVector = _listAddAll(this.queryVector, list); + return this; + } + + /** + * Required - The query vector. + *

+ * API name: {@code query_vector} + *

+ * Adds one or more values to queryVector. + */ + public final Builder queryVector(Float value, Float... values) { + this.queryVector = _listAdd(this.queryVector, value, values); + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalQueryVector}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalQueryVector build() { + _checkSingleUse(); + + return new KnnEvalQueryVector(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalQueryVector} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, KnnEvalQueryVector::setupKnnEvalQueryVectorDeserializer); + + protected static void setupKnnEvalQueryVectorDeserializer(ObjectDeserializer op) { + + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(Builder::queryVector, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.floatDeserializer()), + "query_vector"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalReportedSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalReportedSettings.java new file mode 100644 index 0000000000..5970f8264b --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalReportedSettings.java @@ -0,0 +1,201 @@ +/* + * 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.core.knn_eval; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.util.Objects; +import java.util.function.Function; +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: _global.knn_eval.KnnEvalReportedSettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalReportedSettings extends KnnEvalSettings { + @Nullable + private final Boolean rescoreWindowCapped; + + @Nullable + private final Boolean quantizedScores; + + // --------------------------------------------------------------------------------------------- + + private KnnEvalReportedSettings(Builder builder) { + super(builder); + + this.rescoreWindowCapped = builder.rescoreWindowCapped; + this.quantizedScores = builder.quantizedScores; + + } + + public static KnnEvalReportedSettings of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * If true, the number of vectors to rescore exceeded the limit of + * 10000. + *

+ * API name: {@code rescore_window_capped} + */ + @Nullable + public final Boolean rescoreWindowCapped() { + return this.rescoreWindowCapped; + } + + /** + * If true, the hits were not rescored, so their scores are + * estimates, and no query is excluded from the mean recall. + *

+ * API name: {@code quantized_scores} + */ + @Nullable + public final Boolean quantizedScores() { + return this.quantizedScores; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + if (this.rescoreWindowCapped != null) { + generator.writeKey("rescore_window_capped"); + generator.write(this.rescoreWindowCapped); + + } + if (this.quantizedScores != null) { + generator.writeKey("quantized_scores"); + generator.write(this.quantizedScores); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalReportedSettings}. + */ + + public static class Builder extends KnnEvalSettings.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private Boolean rescoreWindowCapped; + + @Nullable + private Boolean quantizedScores; + + public Builder() { + } + private Builder(KnnEvalReportedSettings instance) { + this.rescoreWindowCapped = instance.rescoreWindowCapped; + this.quantizedScores = instance.quantizedScores; + + } + /** + * If true, the number of vectors to rescore exceeded the limit of + * 10000. + *

+ * API name: {@code rescore_window_capped} + */ + public final Builder rescoreWindowCapped(@Nullable Boolean value) { + this.rescoreWindowCapped = value; + return this; + } + + /** + * If true, the hits were not rescored, so their scores are + * estimates, and no query is excluded from the mean recall. + *

+ * API name: {@code quantized_scores} + */ + public final Builder quantizedScores(@Nullable Boolean value) { + this.quantizedScores = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalReportedSettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalReportedSettings build() { + _checkSingleUse(); + + return new KnnEvalReportedSettings(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalReportedSettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, KnnEvalReportedSettings::setupKnnEvalReportedSettingsDeserializer); + + protected static void setupKnnEvalReportedSettingsDeserializer( + ObjectDeserializer op) { + KnnEvalSettings.setupKnnEvalSettingsDeserializer(op); + op.add(Builder::rescoreWindowCapped, JsonpDeserializer.booleanDeserializer(), "rescore_window_capped"); + op.add(Builder::quantizedScores, JsonpDeserializer.booleanDeserializer(), "quantized_scores"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalResult.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalResult.java new file mode 100644 index 0000000000..8d0eecfeb3 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalResult.java @@ -0,0 +1,337 @@ +/* + * 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.core.knn_eval; + +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.JsonpUtils; +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.Double; +import java.lang.Long; +import java.util.Objects; +import java.util.function.Function; +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: _global.knn_eval.KnnEvalResult + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalResult implements JsonpSerializable { + private final KnnEvalReportedSettings knnSettings; + + @Nullable + private final Double recall; + + private final long includedQueries; + + private final long excludedQueries; + + private final long tookMs; + + private final long vectorOps; + + // --------------------------------------------------------------------------------------------- + + private KnnEvalResult(Builder builder) { + + this.knnSettings = ApiTypeHelper.requireNonNull(builder.knnSettings, this, "knnSettings"); + this.recall = builder.recall; + this.includedQueries = ApiTypeHelper.requireNonNull(builder.includedQueries, this, "includedQueries", 0); + this.excludedQueries = ApiTypeHelper.requireNonNull(builder.excludedQueries, this, "excludedQueries", 0); + this.tookMs = ApiTypeHelper.requireNonNull(builder.tookMs, this, "tookMs", 0); + this.vectorOps = ApiTypeHelper.requireNonNull(builder.vectorOps, this, "vectorOps", 0); + + } + + public static KnnEvalResult of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The evaluated settings. + *

+ * API name: {@code knn_settings} + */ + public final KnnEvalReportedSettings knnSettings() { + return this.knnSettings; + } + + /** + * The mean recall of the included queries, or null if no query is + * included. + *

+ * API name: {@code recall} + */ + @Nullable + public final Double recall() { + return this.recall; + } + + /** + * Required - The number of queries included in the mean recall. + *

+ * API name: {@code included_queries} + */ + public final long includedQueries() { + return this.includedQueries; + } + + /** + * Required - The number of queries excluded from the mean recall, because the + * search found a document scoring above the baseline's lowest top + * k score. + *

+ * API name: {@code excluded_queries} + */ + public final long excludedQueries() { + return this.excludedQueries; + } + + /** + * Required - The time the searches took, in milliseconds. + *

+ * API name: {@code took_ms} + */ + public final long tookMs() { + return this.tookMs; + } + + /** + * Required - The number of vector operations of the searches. + *

+ * API name: {@code vector_ops} + */ + public final long vectorOps() { + return this.vectorOps; + } + + /** + * 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("knn_settings"); + this.knnSettings.serialize(generator, mapper); + + if (this.recall != null) { + generator.writeKey("recall"); + generator.write(this.recall); + + } + generator.writeKey("included_queries"); + generator.write(this.includedQueries); + + generator.writeKey("excluded_queries"); + generator.write(this.excludedQueries); + + generator.writeKey("took_ms"); + generator.write(this.tookMs); + + generator.writeKey("vector_ops"); + generator.write(this.vectorOps); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalResult}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private KnnEvalReportedSettings knnSettings; + + @Nullable + private Double recall; + + private Long includedQueries; + + private Long excludedQueries; + + private Long tookMs; + + private Long vectorOps; + + public Builder() { + } + private Builder(KnnEvalResult instance) { + this.knnSettings = instance.knnSettings; + this.recall = instance.recall; + this.includedQueries = instance.includedQueries; + this.excludedQueries = instance.excludedQueries; + this.tookMs = instance.tookMs; + this.vectorOps = instance.vectorOps; + + } + /** + * Required - The evaluated settings. + *

+ * API name: {@code knn_settings} + */ + public final Builder knnSettings(KnnEvalReportedSettings value) { + this.knnSettings = value; + return this; + } + + /** + * Required - The evaluated settings. + *

+ * API name: {@code knn_settings} + */ + public final Builder knnSettings( + Function> fn) { + return this.knnSettings(fn.apply(new KnnEvalReportedSettings.Builder()).build()); + } + + /** + * The mean recall of the included queries, or null if no query is + * included. + *

+ * API name: {@code recall} + */ + public final Builder recall(@Nullable Double value) { + this.recall = value; + return this; + } + + /** + * Required - The number of queries included in the mean recall. + *

+ * API name: {@code included_queries} + */ + public final Builder includedQueries(long value) { + this.includedQueries = value; + return this; + } + + /** + * Required - The number of queries excluded from the mean recall, because the + * search found a document scoring above the baseline's lowest top + * k score. + *

+ * API name: {@code excluded_queries} + */ + public final Builder excludedQueries(long value) { + this.excludedQueries = value; + return this; + } + + /** + * Required - The time the searches took, in milliseconds. + *

+ * API name: {@code took_ms} + */ + public final Builder tookMs(long value) { + this.tookMs = value; + return this; + } + + /** + * Required - The number of vector operations of the searches. + *

+ * API name: {@code vector_ops} + */ + public final Builder vectorOps(long value) { + this.vectorOps = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalResult}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalResult build() { + _checkSingleUse(); + + return new KnnEvalResult(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalResult} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + KnnEvalResult::setupKnnEvalResultDeserializer); + + protected static void setupKnnEvalResultDeserializer(ObjectDeserializer op) { + + op.add(Builder::knnSettings, KnnEvalReportedSettings._DESERIALIZER, "knn_settings"); + op.add(Builder::recall, JsonpDeserializer.doubleDeserializer(), "recall"); + op.add(Builder::includedQueries, JsonpDeserializer.longDeserializer(), "included_queries"); + op.add(Builder::excludedQueries, JsonpDeserializer.longDeserializer(), "excluded_queries"); + op.add(Builder::tookMs, JsonpDeserializer.longDeserializer(), "took_ms"); + op.add(Builder::vectorOps, JsonpDeserializer.longDeserializer(), "vector_ops"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalSettings.java new file mode 100644 index 0000000000..a7d0594fc2 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalSettings.java @@ -0,0 +1,292 @@ +/* + * 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.core.knn_eval; + +import co.elastic.clients.elasticsearch._types.RescoreVector; +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.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.Float; +import java.lang.Integer; +import java.util.Objects; +import java.util.function.Function; +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: _global.knn_eval.KnnEvalSettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalSettings implements JsonpSerializable { + @Nullable + private final Float visitPercentage; + + @Nullable + private final Integer numCandidates; + + @Nullable + private final RescoreVector rescoreVector; + + @Nullable + private final Boolean exact; + + // --------------------------------------------------------------------------------------------- + + protected KnnEvalSettings(AbstractBuilder builder) { + + this.visitPercentage = builder.visitPercentage; + this.numCandidates = builder.numCandidates; + this.rescoreVector = builder.rescoreVector; + this.exact = builder.exact; + + } + + public static KnnEvalSettings knnEvalSettingsOf(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The percentage of postings to visit, from 0 to 100. 0 selects + * the automatic visit calculation. + *

+ * API name: {@code visit_percentage} + */ + @Nullable + public final Float visitPercentage() { + return this.visitPercentage; + } + + /** + * The number of nearest neighbor candidates to consider per shard. It can't be + * less than k, or more than 10000 (9999 with sampling). + *

+ * API name: {@code num_candidates} + */ + @Nullable + public final Integer numCandidates() { + return this.numCandidates; + } + + /** + * The rescoring of the candidates. Only applies to quantized fields. + *

+ * API name: {@code rescore_vector} + */ + @Nullable + public final RescoreVector rescoreVector() { + return this.rescoreVector; + } + + /** + * If true, compares every vector at full precision. Only applies + * to the baseline, requires allow_exact_baseline, and + * can't be combined with other settings. + *

+ * API name: {@code exact} + */ + @Nullable + public final Boolean exact() { + return this.exact; + } + + /** + * 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 (this.visitPercentage != null) { + generator.writeKey("visit_percentage"); + generator.write(this.visitPercentage); + + } + if (this.numCandidates != null) { + generator.writeKey("num_candidates"); + generator.write(this.numCandidates); + + } + if (this.rescoreVector != null) { + generator.writeKey("rescore_vector"); + this.rescoreVector.serialize(generator, mapper); + + } + if (this.exact != null) { + generator.writeKey("exact"); + generator.write(this.exact); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalSettings}. + */ + + public static class Builder extends KnnEvalSettings.AbstractBuilder + implements + ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalSettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalSettings build() { + _checkSingleUse(); + + return new KnnEvalSettings(this); + } + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + @Nullable + private Float visitPercentage; + + @Nullable + private Integer numCandidates; + + @Nullable + private RescoreVector rescoreVector; + + @Nullable + private Boolean exact; + + /** + * The percentage of postings to visit, from 0 to 100. 0 selects + * the automatic visit calculation. + *

+ * API name: {@code visit_percentage} + */ + public final BuilderT visitPercentage(@Nullable Float value) { + this.visitPercentage = value; + return self(); + } + + /** + * The number of nearest neighbor candidates to consider per shard. It can't be + * less than k, or more than 10000 (9999 with sampling). + *

+ * API name: {@code num_candidates} + */ + public final BuilderT numCandidates(@Nullable Integer value) { + this.numCandidates = value; + return self(); + } + + /** + * The rescoring of the candidates. Only applies to quantized fields. + *

+ * API name: {@code rescore_vector} + */ + public final BuilderT rescoreVector(@Nullable RescoreVector value) { + this.rescoreVector = value; + return self(); + } + + /** + * The rescoring of the candidates. Only applies to quantized fields. + *

+ * API name: {@code rescore_vector} + */ + public final BuilderT rescoreVector(Function> fn) { + return this.rescoreVector(fn.apply(new RescoreVector.Builder()).build()); + } + + /** + * If true, compares every vector at full precision. Only applies + * to the baseline, requires allow_exact_baseline, and + * can't be combined with other settings. + *

+ * API name: {@code exact} + */ + public final BuilderT exact(@Nullable Boolean value) { + this.exact = value; + return self(); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalSettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + KnnEvalSettings::setupKnnEvalSettingsDeserializer); + + protected static > void setupKnnEvalSettingsDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::visitPercentage, JsonpDeserializer.floatDeserializer(), "visit_percentage"); + op.add(AbstractBuilder::numCandidates, JsonpDeserializer.integerDeserializer(), "num_candidates"); + op.add(AbstractBuilder::rescoreVector, RescoreVector._DESERIALIZER, "rescore_vector"); + op.add(AbstractBuilder::exact, JsonpDeserializer.booleanDeserializer(), "exact"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalVectorOpsKind.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalVectorOpsKind.java new file mode 100644 index 0000000000..691eb43150 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalVectorOpsKind.java @@ -0,0 +1,73 @@ +/* + * 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.core.knn_eval; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum KnnEvalVectorOpsKind implements JsonEnum { + /** + * Full-precision comparisons across all the matching vectors. + */ + FullPrecisionScan("full_precision_scan"), + + /** + * Quantized visits plus full-precision rescoring. + */ + QuantizedVisitPlusRescore("quantized_visit_plus_rescore"), + + ; + + private final String jsonValue; + + KnnEvalVectorOpsKind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + KnnEvalVectorOpsKind.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalVectorsQuerySource.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalVectorsQuerySource.java new file mode 100644 index 0000000000..180b8215a5 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/knn_eval/KnnEvalVectorsQuerySource.java @@ -0,0 +1,218 @@ +/* + * 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.core.knn_eval; + +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.JsonpUtils; +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.util.List; +import java.util.Objects; +import java.util.function.Function; +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: _global.knn_eval.KnnEvalVectorsQuerySource + +/** + * Uses the query vectors in the request. + * + * @see API + * specification + */ +@JsonpDeserializable +public class KnnEvalVectorsQuerySource implements KnnEvalQuerySourceVariant, JsonpSerializable { + private final List vectors; + + // --------------------------------------------------------------------------------------------- + + private KnnEvalVectorsQuerySource(Builder builder) { + + this.vectors = ApiTypeHelper.unmodifiableRequired(builder.vectors, this, "vectors"); + + } + + public static KnnEvalVectorsQuerySource of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * KnnEvalQuerySource variant kind. + */ + @Override + public KnnEvalQuerySource.Kind _knnEvalQuerySourceKind() { + return KnnEvalQuerySource.Kind.Vectors; + } + + /** + * Required - The query vectors, from 1 to 1000 entries with unique identifiers. + *

+ * API name: {@code vectors} + */ + public final List vectors() { + return this.vectors; + } + + /** + * 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.write("from", "vectors"); + + if (ApiTypeHelper.isDefined(this.vectors)) { + generator.writeKey("vectors"); + generator.writeStartArray(); + for (KnnEvalQueryVector item0 : this.vectors) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnEvalVectorsQuerySource}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private List vectors; + + public Builder() { + } + private Builder(KnnEvalVectorsQuerySource instance) { + this.vectors = instance.vectors; + + } + /** + * Required - The query vectors, from 1 to 1000 entries with unique identifiers. + *

+ * API name: {@code vectors} + *

+ * Adds all elements of list to vectors. + */ + public final Builder vectors(List list) { + this.vectors = _listAddAll(this.vectors, list); + return this; + } + + /** + * Required - The query vectors, from 1 to 1000 entries with unique identifiers. + *

+ * API name: {@code vectors} + *

+ * Adds one or more values to vectors. + */ + public final Builder vectors(KnnEvalQueryVector value, KnnEvalQueryVector... values) { + this.vectors = _listAdd(this.vectors, value, values); + return this; + } + + /** + * Required - The query vectors, from 1 to 1000 entries with unique identifiers. + *

+ * API name: {@code vectors} + *

+ * Adds a value to vectors using a builder lambda. + */ + public final Builder vectors(Function> fn) { + return vectors(fn.apply(new KnnEvalQueryVector.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnEvalVectorsQuerySource}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KnnEvalVectorsQuerySource build() { + _checkSingleUse(); + + return new KnnEvalVectorsQuerySource(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnEvalVectorsQuerySource} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, KnnEvalVectorsQuerySource::setupKnnEvalVectorsQuerySourceDeserializer); + + protected static void setupKnnEvalVectorsQuerySourceDeserializer( + ObjectDeserializer op) { + + op.add(Builder::vectors, JsonpDeserializer.arrayDeserializer(KnnEvalQueryVector._DESERIALIZER), "vectors"); + + op.ignore("from"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mget/MultiGetOperation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mget/MultiGetOperation.java index 17f26d16c6..bb7c245dad 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mget/MultiGetOperation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mget/MultiGetOperation.java @@ -70,6 +70,9 @@ public class MultiGetOperation implements JsonpSerializable { private final List routing; + @Nullable + private final String routeSlice; + @Nullable private final SourceConfig source; @@ -88,6 +91,7 @@ private MultiGetOperation(Builder builder) { this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); this.index = builder.index; this.routing = ApiTypeHelper.unmodifiable(builder.routing); + this.routeSlice = builder.routeSlice; this.source = builder.source; this.storedFields = ApiTypeHelper.unmodifiable(builder.storedFields); this.version = builder.version; @@ -120,7 +124,8 @@ public final String index() { /** * The key for the primary shard the document resides on. Required if routing is - * used during indexing. + * used during indexing. Not allowed when index.slice.enabled is + * true for the target index; use _slice instead. *

* API name: {@code routing} */ @@ -128,6 +133,18 @@ public final List routing() { return this.routing; } + /** + * The slice the document belongs to, for a slice-enabled index + * (index.slice.enabled set to true). It overrides the + * _slice set in the request path. + *

+ * API name: {@code _slice} + */ + @Nullable + public final String routeSlice() { + return this.routeSlice; + } + /** * If false, excludes all _source fields. *

@@ -191,6 +208,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } generator.writeEnd(); + } + if (this.routeSlice != null) { + generator.writeKey("_slice"); + generator.write(this.routeSlice); + } if (this.source != null) { generator.writeKey("_source"); @@ -239,6 +261,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private List routing; + @Nullable + private String routeSlice; + @Nullable private SourceConfig source; @@ -257,6 +282,7 @@ private Builder(MultiGetOperation instance) { this.id = instance.id; this.index = instance.index; this.routing = instance.routing; + this.routeSlice = instance.routeSlice; this.source = instance.source; this.storedFields = instance.storedFields; this.version = instance.version; @@ -285,7 +311,8 @@ public final Builder index(@Nullable String value) { /** * The key for the primary shard the document resides on. Required if routing is - * used during indexing. + * used during indexing. Not allowed when index.slice.enabled is + * true for the target index; use _slice instead. *

* API name: {@code routing} *

@@ -298,7 +325,8 @@ public final Builder routing(List list) { /** * The key for the primary shard the document resides on. Required if routing is - * used during indexing. + * used during indexing. Not allowed when index.slice.enabled is + * true for the target index; use _slice instead. *

* API name: {@code routing} *

@@ -309,6 +337,18 @@ public final Builder routing(String value, String... values) { return this; } + /** + * The slice the document belongs to, for a slice-enabled index + * (index.slice.enabled set to true). It overrides the + * _slice set in the request path. + *

+ * API name: {@code _slice} + */ + public final Builder routeSlice(@Nullable String value) { + this.routeSlice = value; + return this; + } + /** * If false, excludes all _source fields. *

@@ -406,6 +446,7 @@ protected static void setupMultiGetOperationDeserializer(ObjectDeserializer_all to query all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * routing value. When omitted, all slices are targeted. *

* API name: {@code _slice} */ @@ -567,9 +565,7 @@ public final Builder ignoreThrottled(@Nullable Boolean value) { /** * The slice identifier for routing the search to a specific slice. Use the * special value _all to query all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * routing value. When omitted, all slices are targeted. *

* API name: {@code _slice} */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mtermvectors/MultiTermVectorsOperation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mtermvectors/MultiTermVectorsOperation.java index aa73828b89..f4e329162f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mtermvectors/MultiTermVectorsOperation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mtermvectors/MultiTermVectorsOperation.java @@ -94,6 +94,9 @@ public class MultiTermVectorsOperation implements JsonpSerializable { private final List routing; + @Nullable + private final String routeSlice; + @Nullable private final Boolean termStatistics; @@ -117,6 +120,7 @@ private MultiTermVectorsOperation(Builder builder) { this.payloads = builder.payloads; this.positions = builder.positions; this.routing = ApiTypeHelper.unmodifiable(builder.routing); + this.routeSlice = builder.routeSlice; this.termStatistics = builder.termStatistics; this.version = builder.version; this.versionType = builder.versionType; @@ -222,7 +226,9 @@ public final Boolean positions() { } /** - * Custom value used to route operations to a specific shard. + * Custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. *

* API name: {@code routing} */ @@ -230,6 +236,18 @@ public final List routing() { return this.routing; } + /** + * The slice the document belongs to, for a slice-enabled index + * (index.slice.enabled set to true). It overrides the + * _slice set in the request path. + *

+ * API name: {@code _slice} + */ + @Nullable + public final String routeSlice() { + return this.routeSlice; + } + /** * If true, the response includes term frequency and document frequency. *

@@ -330,6 +348,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } generator.writeEnd(); + } + if (this.routeSlice != null) { + generator.writeKey("_slice"); + generator.write(this.routeSlice); + } if (this.termStatistics != null) { generator.writeKey("term_statistics"); @@ -392,6 +415,9 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private List routing; + @Nullable + private String routeSlice; + @Nullable private Boolean termStatistics; @@ -414,6 +440,7 @@ private Builder(MultiTermVectorsOperation instance) { this.payloads = instance.payloads; this.positions = instance.positions; this.routing = instance.routing; + this.routeSlice = instance.routeSlice; this.termStatistics = instance.termStatistics; this.version = instance.version; this.versionType = instance.versionType; @@ -541,7 +568,9 @@ public final Builder positions(@Nullable Boolean value) { } /** - * Custom value used to route operations to a specific shard. + * Custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. *

* API name: {@code routing} *

@@ -553,7 +582,9 @@ public final Builder routing(List list) { } /** - * Custom value used to route operations to a specific shard. + * Custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. *

* API name: {@code routing} *

@@ -564,6 +595,18 @@ public final Builder routing(String value, String... values) { return this; } + /** + * The slice the document belongs to, for a slice-enabled index + * (index.slice.enabled set to true). It overrides the + * _slice set in the request path. + *

+ * API name: {@code _slice} + */ + public final Builder routeSlice(@Nullable String value) { + this.routeSlice = value; + return this; + } + /** * If true, the response includes term frequency and document frequency. *

@@ -640,6 +683,7 @@ protected static void setupMultiTermVectorsOperationDeserializer( op.add(Builder::positions, JsonpDeserializer.booleanDeserializer(), "positions"); op.add(Builder::routing, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "routing"); + op.add(Builder::routeSlice, JsonpDeserializer.stringDeserializer(), "_slice"); op.add(Builder::termStatistics, JsonpDeserializer.booleanDeserializer(), "term_statistics"); op.add(Builder::version, JsonpDeserializer.longDeserializer(), "version"); op.add(Builder::versionType, VersionType._DESERIALIZER, "version_type"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/rank_eval/RankEvalMetricDetail.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/rank_eval/RankEvalMetricDetail.java index 3561a236d4..389536d40c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/rank_eval/RankEvalMetricDetail.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/rank_eval/RankEvalMetricDetail.java @@ -32,6 +32,7 @@ import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; import java.lang.Double; +import java.lang.Long; import java.lang.String; import java.util.List; import java.util.Map; @@ -66,6 +67,8 @@ public class RankEvalMetricDetail implements JsonpSerializable { private final double metricScore; + private final long took; + private final List unratedDocs; private final List hits; @@ -77,6 +80,7 @@ public class RankEvalMetricDetail implements JsonpSerializable { private RankEvalMetricDetail(Builder builder) { this.metricScore = ApiTypeHelper.requireNonNull(builder.metricScore, this, "metricScore", 0); + this.took = ApiTypeHelper.requireNonNull(builder.took, this, "took", 0); this.unratedDocs = ApiTypeHelper.unmodifiableRequired(builder.unratedDocs, this, "unratedDocs"); this.hits = ApiTypeHelper.unmodifiableRequired(builder.hits, this, "hits"); this.metricDetails = ApiTypeHelper.unmodifiableRequired(builder.metricDetails, this, "metricDetails"); @@ -97,6 +101,16 @@ public final double metricScore() { return this.metricScore; } + /** + * Required - The time in milliseconds it took to execute the search request for + * this query + *

+ * API name: {@code took} + */ + public final long took() { + return this.took; + } + /** * Required - The unrated_docs section contains an _index and _id entry for each * document in the search result for this query that didn’t have a ratings @@ -144,6 +158,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("metric_score"); generator.write(this.metricScore); + generator.writeKey("took"); + generator.write(this.took); + if (ApiTypeHelper.isDefined(this.unratedDocs)) { generator.writeKey("unrated_docs"); generator.writeStartArray(); @@ -202,6 +219,8 @@ public static class Builder extends WithJsonObjectBuilderBase ObjectBuilder { private Double metricScore; + private Long took; + private List unratedDocs; private List hits; @@ -212,6 +231,7 @@ public Builder() { } private Builder(RankEvalMetricDetail instance) { this.metricScore = instance.metricScore; + this.took = instance.took; this.unratedDocs = instance.unratedDocs; this.hits = instance.hits; this.metricDetails = instance.metricDetails; @@ -228,6 +248,17 @@ public final Builder metricScore(double value) { return this; } + /** + * Required - The time in milliseconds it took to execute the search request for + * this query + *

+ * API name: {@code took} + */ + public final Builder took(long value) { + this.took = value; + return this; + } + /** * Required - The unrated_docs section contains an _index and _id entry for each * document in the search result for this query that didn’t have a ratings @@ -372,6 +403,7 @@ public Builder rebuild() { protected static void setupRankEvalMetricDetailDeserializer(ObjectDeserializer op) { op.add(Builder::metricScore, JsonpDeserializer.doubleDeserializer(), "metric_score"); + op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); op.add(Builder::unratedDocs, JsonpDeserializer.arrayDeserializer(UnratedDocument._DESERIALIZER), "unrated_docs"); op.add(Builder::hits, JsonpDeserializer.arrayDeserializer(RankEvalHitItem._DESERIALIZER), "hits"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/rank_eval/RankEvalTemplate.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/rank_eval/RankEvalTemplate.java new file mode 100644 index 0000000000..c26e4a5e95 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/rank_eval/RankEvalTemplate.java @@ -0,0 +1,226 @@ +/* + * 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.core.rank_eval; + +import co.elastic.clients.elasticsearch._types.Script; +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: _global.rank_eval.RankEvalTemplate + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class RankEvalTemplate implements JsonpSerializable { + private final String id; + + private final Script template; + + // --------------------------------------------------------------------------------------------- + + private RankEvalTemplate(Builder builder) { + + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.template = ApiTypeHelper.requireNonNull(builder.template, this, "template"); + + } + + public static RankEvalTemplate of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The ID of the template. A rated request refers to it by this ID in + * its template_id. + *

+ * API name: {@code id} + */ + public final String id() { + return this.id; + } + + /** + * Required - The search template, either an inline source or the + * id of a stored search template. It must be a + * mustache template (the default lang), and it must + * render to a search request body. Any params set here are + * ignored: each rated request provides its own params, which are + * used to render the template. + *

+ * API name: {@code template} + */ + public final Script template() { + return this.template; + } + + /** + * 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("id"); + generator.write(this.id); + + generator.writeKey("template"); + this.template.serialize(generator, mapper); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RankEvalTemplate}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private String id; + + private Script template; + + public Builder() { + } + private Builder(RankEvalTemplate instance) { + this.id = instance.id; + this.template = instance.template; + + } + /** + * Required - The ID of the template. A rated request refers to it by this ID in + * its template_id. + *

+ * API name: {@code id} + */ + public final Builder id(String value) { + this.id = value; + return this; + } + + /** + * Required - The search template, either an inline source or the + * id of a stored search template. It must be a + * mustache template (the default lang), and it must + * render to a search request body. Any params set here are + * ignored: each rated request provides its own params, which are + * used to render the template. + *

+ * API name: {@code template} + */ + public final Builder template(Script value) { + this.template = value; + return this; + } + + /** + * Required - The search template, either an inline source or the + * id of a stored search template. It must be a + * mustache template (the default lang), and it must + * render to a search request body. Any params set here are + * ignored: each rated request provides its own params, which are + * used to render the template. + *

+ * API name: {@code template} + */ + public final Builder template(Function> fn) { + return this.template(fn.apply(new Script.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link RankEvalTemplate}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RankEvalTemplate build() { + _checkSingleUse(); + + return new RankEvalTemplate(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RankEvalTemplate} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + RankEvalTemplate::setupRankEvalTemplateDeserializer); + + protected static void setupRankEvalTemplateDeserializer(ObjectDeserializer op) { + + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(Builder::template, Script._DESERIALIZER, "template"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/reindex/Destination.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/reindex/Destination.java index 3a00fff1db..85173a2e65 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/reindex/Destination.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/reindex/Destination.java @@ -148,11 +148,12 @@ public final String routing() { /** * The slice identifier used to route the reindexed documents to a specific - * slice of the destination index. Use the special value _all to - * target all slices without restricting to a routing value. Required when - * index.slice.enabled is true for the destination - * index; not allowed when index.slice.enabled is - * false. + * slice of the destination index. Not allowed when + * index.slice.enabled is false for the destination + * index. When index.slice.enabled is true, it is + * required unless the source is read with _slice, in which case + * each document keeps its source slice, or a script sets + * ctx._slice. *

* API name: {@code _slice} */ @@ -305,11 +306,12 @@ public final Builder routing(@Nullable String value) { /** * The slice identifier used to route the reindexed documents to a specific - * slice of the destination index. Use the special value _all to - * target all slices without restricting to a routing value. Required when - * index.slice.enabled is true for the destination - * index; not allowed when index.slice.enabled is - * false. + * slice of the destination index. Not allowed when + * index.slice.enabled is false for the destination + * index. When index.slice.enabled is true, it is + * required unless the source is read with _slice, in which case + * each document keeps its source slice, or a script sets + * ctx._slice. *

* API name: {@code _slice} */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/reindex/Source.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/reindex/Source.java index de47a9e486..3300224e1a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/reindex/Source.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/reindex/Source.java @@ -85,6 +85,9 @@ public class Source implements JsonpSerializable { @Nullable private final SlicedScroll slice; + @Nullable + private final String routeSlice; + private final List sort; @Nullable @@ -102,6 +105,7 @@ private Source(Builder builder) { this.projectRouting = builder.projectRouting; this.size = builder.size; this.slice = builder.slice; + this.routeSlice = builder.routeSlice; this.sort = ApiTypeHelper.unmodifiable(builder.sort); this.sourceFields = builder.sourceFields; this.runtimeMappings = ApiTypeHelper.unmodifiable(builder.runtimeMappings); @@ -179,6 +183,20 @@ public final SlicedScroll slice() { return this.slice; } + /** + * The slice of a slice-enabled source index (index.slice.enabled + * set to true) to read, or _all to read all slices. + * The reindexed documents keep the slice they are read from, unless + * _slice is set in dest. Not supported when + * reindexing from a remote cluster. + *

+ * API name: {@code _slice} + */ + @Nullable + public final String routeSlice() { + return this.routeSlice; + } + /** * A comma-separated list of <field>:<direction> pairs * to sort by before indexing. Use it in conjunction with max_docs @@ -262,6 +280,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); + } + if (this.routeSlice != null) { + generator.writeKey("_slice"); + generator.write(this.routeSlice); + } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); @@ -321,6 +344,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private SlicedScroll slice; + @Nullable + private String routeSlice; + @Nullable private List sort; @@ -339,6 +365,7 @@ private Builder(Source instance) { this.projectRouting = instance.projectRouting; this.size = instance.size; this.slice = instance.slice; + this.routeSlice = instance.routeSlice; this.sort = instance.sort; this.sourceFields = instance.sourceFields; this.runtimeMappings = instance.runtimeMappings; @@ -465,6 +492,20 @@ public final Builder slice(Functionindex.slice.enabled + * set to true) to read, or _all to read all slices. + * The reindexed documents keep the slice they are read from, unless + * _slice is set in dest. Not supported when + * reindexing from a remote cluster. + *

+ * API name: {@code _slice} + */ + public final Builder routeSlice(@Nullable String value) { + this.routeSlice = value; + return this; + } + /** * A comma-separated list of <field>:<direction> pairs * to sort by before indexing. Use it in conjunction with max_docs @@ -624,6 +665,7 @@ protected static void setupSourceDeserializer(ObjectDeserializer op.add(Builder::projectRouting, JsonpDeserializer.stringDeserializer(), "project_routing"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); + op.add(Builder::routeSlice, JsonpDeserializer.stringDeserializer(), "_slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::sourceFields, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer(RuntimeField._DESERIALIZER), diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/FieldCollapse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/FieldCollapse.java index 31cca45681..cd666f612a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/FieldCollapse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/FieldCollapse.java @@ -69,9 +69,6 @@ public class FieldCollapse implements JsonpSerializable { @Nullable private final Integer maxConcurrentGroupSearches; - @Nullable - private final FieldCollapse collapse; - // --------------------------------------------------------------------------------------------- private FieldCollapse(Builder builder) { @@ -79,7 +76,6 @@ private FieldCollapse(Builder builder) { this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); this.innerHits = ApiTypeHelper.unmodifiable(builder.innerHits); this.maxConcurrentGroupSearches = builder.maxConcurrentGroupSearches; - this.collapse = builder.collapse; } @@ -116,14 +112,6 @@ public final Integer maxConcurrentGroupSearches() { return this.maxConcurrentGroupSearches; } - /** - * API name: {@code collapse} - */ - @Nullable - public final FieldCollapse collapse() { - return this.collapse; - } - /** * Serialize this object to JSON. */ @@ -153,11 +141,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.maxConcurrentGroupSearches); } - if (this.collapse != null) { - generator.writeKey("collapse"); - this.collapse.serialize(generator, mapper); - - } } @@ -181,16 +164,12 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private Integer maxConcurrentGroupSearches; - @Nullable - private FieldCollapse collapse; - public Builder() { } private Builder(FieldCollapse instance) { this.field = instance.field; this.innerHits = instance.innerHits; this.maxConcurrentGroupSearches = instance.maxConcurrentGroupSearches; - this.collapse = instance.collapse; } /** @@ -249,21 +228,6 @@ public final Builder maxConcurrentGroupSearches(@Nullable Integer value) { return this; } - /** - * API name: {@code collapse} - */ - public final Builder collapse(@Nullable FieldCollapse value) { - this.collapse = value; - return this; - } - - /** - * API name: {@code collapse} - */ - public final Builder collapse(Function> fn) { - return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); - } - @Override protected Builder self() { return this; @@ -302,7 +266,6 @@ protected static void setupFieldCollapseDeserializer(ObjectDeserializer implements JsonpSerializable { @Nullable private final String routing; + @Nullable + private final String slice; + @Nullable private final TDocument source; @@ -143,6 +146,7 @@ private Hit(Builder builder) { this.shard = builder.shard; this.node = builder.node; this.routing = builder.routing; + this.slice = builder.slice; this.source = builder.source; this.rank = builder.rank; this.seqNo = builder.seqNo; @@ -262,6 +266,17 @@ public final String routing() { return this.routing; } + /** + * The slice the document belongs to, for a slice-enabled index + * (index.slice.enabled set to true). + *

+ * API name: {@code _slice} + */ + @Nullable + public final String slice() { + return this.slice; + } + /** * API name: {@code _source} */ @@ -444,6 +459,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("_routing"); generator.write(this.routing); + } + if (this.slice != null) { + generator.writeKey("_slice"); + generator.write(this.slice); + } if (this.source != null) { generator.writeKey("_source"); @@ -538,6 +558,9 @@ public static class Builder extends WithJsonObjectBuilderBase instance) { this.shard = instance.shard; this.node = instance.node; this.routing = instance.routing; + this.slice = instance.slice; this.source = instance.source; this.rank = instance.rank; this.seqNo = instance.seqNo; @@ -792,6 +816,17 @@ public final Builder routing(@Nullable String value) { return this; } + /** + * The slice the document belongs to, for a slice-enabled index + * (index.slice.enabled set to true). + *

+ * API name: {@code _slice} + */ + public final Builder slice(@Nullable String value) { + this.slice = value; + return this; + } + /** * API name: {@code _source} */ @@ -989,6 +1024,7 @@ protected static void setupHitDeserializer(ObjectDeserializerAPI + * specification + */ +@JsonpDeserializable +public class LearningToRankRescoreProfile extends RescoreProfileBase implements RescoreProfileVariant { + private final LearningToRankRescoreProfileBreakdown breakdown; + + // --------------------------------------------------------------------------------------------- + + private LearningToRankRescoreProfile(Builder builder) { + super(builder); + + this.breakdown = ApiTypeHelper.requireNonNull(builder.breakdown, this, "breakdown"); + + } + + public static LearningToRankRescoreProfile of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * RescoreProfile variant kind. + */ + @Override + public RescoreProfile.Kind _rescoreProfileKind() { + return RescoreProfile.Kind.LearningToRank; + } + + /** + * Required - API name: {@code breakdown} + */ + public final LearningToRankRescoreProfileBreakdown breakdown() { + return this.breakdown; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "learning_to_rank"); + super.serializeInternal(generator, mapper); + generator.writeKey("breakdown"); + this.breakdown.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link LearningToRankRescoreProfile}. + */ + + public static class Builder extends RescoreProfileBase.AbstractBuilder + implements + ObjectBuilder { + private LearningToRankRescoreProfileBreakdown breakdown; + + public Builder() { + } + private Builder(LearningToRankRescoreProfile instance) { + this.breakdown = instance.breakdown; + + } + /** + * Required - API name: {@code breakdown} + */ + public final Builder breakdown(LearningToRankRescoreProfileBreakdown value) { + this.breakdown = value; + return this; + } + + /** + * Required - API name: {@code breakdown} + */ + public final Builder breakdown( + Function> fn) { + return this.breakdown(fn.apply(new LearningToRankRescoreProfileBreakdown.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link LearningToRankRescoreProfile}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public LearningToRankRescoreProfile build() { + _checkSingleUse(); + + return new LearningToRankRescoreProfile(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link LearningToRankRescoreProfile} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, LearningToRankRescoreProfile::setupLearningToRankRescoreProfileDeserializer); + + protected static void setupLearningToRankRescoreProfileDeserializer( + ObjectDeserializer op) { + RescoreProfileBase.setupRescoreProfileBaseDeserializer(op); + op.add(Builder::breakdown, LearningToRankRescoreProfileBreakdown._DESERIALIZER, "breakdown"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/LearningToRankRescoreProfileBreakdown.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/LearningToRankRescoreProfileBreakdown.java new file mode 100644 index 0000000000..26a6abf6c2 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/LearningToRankRescoreProfileBreakdown.java @@ -0,0 +1,313 @@ +/* + * 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.core.search; + +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.JsonpUtils; +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.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: _global.search._types.LearningToRankRescoreProfileBreakdown + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class LearningToRankRescoreProfileBreakdown implements JsonpSerializable { + private final long buildFeatureExtractors; + + private final long buildFeatureExtractorsCount; + + private final long featureExtraction; + + private final long featureExtractionCount; + + private final long inference; + + private final long inferenceCount; + + // --------------------------------------------------------------------------------------------- + + private LearningToRankRescoreProfileBreakdown(Builder builder) { + + this.buildFeatureExtractors = ApiTypeHelper.requireNonNull(builder.buildFeatureExtractors, this, + "buildFeatureExtractors", 0); + this.buildFeatureExtractorsCount = ApiTypeHelper.requireNonNull(builder.buildFeatureExtractorsCount, this, + "buildFeatureExtractorsCount", 0); + this.featureExtraction = ApiTypeHelper.requireNonNull(builder.featureExtraction, this, "featureExtraction", 0); + this.featureExtractionCount = ApiTypeHelper.requireNonNull(builder.featureExtractionCount, this, + "featureExtractionCount", 0); + this.inference = ApiTypeHelper.requireNonNull(builder.inference, this, "inference", 0); + this.inferenceCount = ApiTypeHelper.requireNonNull(builder.inferenceCount, this, "inferenceCount", 0); + + } + + public static LearningToRankRescoreProfileBreakdown of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The time spent turning the feature queries of the model into + * queries that can score documents. + *

+ * API name: {@code build_feature_extractors} + */ + public final long buildFeatureExtractors() { + return this.buildFeatureExtractors; + } + + /** + * Required - API name: {@code build_feature_extractors_count} + */ + public final long buildFeatureExtractorsCount() { + return this.buildFeatureExtractorsCount; + } + + /** + * Required - The time spent extracting the features of the top documents. + *

+ * API name: {@code feature_extraction} + */ + public final long featureExtraction() { + return this.featureExtraction; + } + + /** + * Required - API name: {@code feature_extraction_count} + */ + public final long featureExtractionCount() { + return this.featureExtractionCount; + } + + /** + * Required - The time spent running the model on the extracted features. + *

+ * API name: {@code inference} + */ + public final long inference() { + return this.inference; + } + + /** + * Required - API name: {@code inference_count} + */ + public final long inferenceCount() { + return this.inferenceCount; + } + + /** + * 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("build_feature_extractors"); + generator.write(this.buildFeatureExtractors); + + generator.writeKey("build_feature_extractors_count"); + generator.write(this.buildFeatureExtractorsCount); + + generator.writeKey("feature_extraction"); + generator.write(this.featureExtraction); + + generator.writeKey("feature_extraction_count"); + generator.write(this.featureExtractionCount); + + generator.writeKey("inference"); + generator.write(this.inference); + + generator.writeKey("inference_count"); + generator.write(this.inferenceCount); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link LearningToRankRescoreProfileBreakdown}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Long buildFeatureExtractors; + + private Long buildFeatureExtractorsCount; + + private Long featureExtraction; + + private Long featureExtractionCount; + + private Long inference; + + private Long inferenceCount; + + public Builder() { + } + private Builder(LearningToRankRescoreProfileBreakdown instance) { + this.buildFeatureExtractors = instance.buildFeatureExtractors; + this.buildFeatureExtractorsCount = instance.buildFeatureExtractorsCount; + this.featureExtraction = instance.featureExtraction; + this.featureExtractionCount = instance.featureExtractionCount; + this.inference = instance.inference; + this.inferenceCount = instance.inferenceCount; + + } + /** + * Required - The time spent turning the feature queries of the model into + * queries that can score documents. + *

+ * API name: {@code build_feature_extractors} + */ + public final Builder buildFeatureExtractors(long value) { + this.buildFeatureExtractors = value; + return this; + } + + /** + * Required - API name: {@code build_feature_extractors_count} + */ + public final Builder buildFeatureExtractorsCount(long value) { + this.buildFeatureExtractorsCount = value; + return this; + } + + /** + * Required - The time spent extracting the features of the top documents. + *

+ * API name: {@code feature_extraction} + */ + public final Builder featureExtraction(long value) { + this.featureExtraction = value; + return this; + } + + /** + * Required - API name: {@code feature_extraction_count} + */ + public final Builder featureExtractionCount(long value) { + this.featureExtractionCount = value; + return this; + } + + /** + * Required - The time spent running the model on the extracted features. + *

+ * API name: {@code inference} + */ + public final Builder inference(long value) { + this.inference = value; + return this; + } + + /** + * Required - API name: {@code inference_count} + */ + public final Builder inferenceCount(long value) { + this.inferenceCount = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link LearningToRankRescoreProfileBreakdown}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public LearningToRankRescoreProfileBreakdown build() { + _checkSingleUse(); + + return new LearningToRankRescoreProfileBreakdown(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link LearningToRankRescoreProfileBreakdown} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + LearningToRankRescoreProfileBreakdown::setupLearningToRankRescoreProfileBreakdownDeserializer); + + protected static void setupLearningToRankRescoreProfileBreakdownDeserializer( + ObjectDeserializer op) { + + op.add(Builder::buildFeatureExtractors, JsonpDeserializer.longDeserializer(), "build_feature_extractors"); + op.add(Builder::buildFeatureExtractorsCount, JsonpDeserializer.longDeserializer(), + "build_feature_extractors_count"); + op.add(Builder::featureExtraction, JsonpDeserializer.longDeserializer(), "feature_extraction"); + op.add(Builder::featureExtractionCount, JsonpDeserializer.longDeserializer(), "feature_extraction_count"); + op.add(Builder::inference, JsonpDeserializer.longDeserializer(), "inference"); + op.add(Builder::inferenceCount, JsonpDeserializer.longDeserializer(), "inference_count"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PointInTimeReference.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PointInTimeReference.java index 782e72f1ee..fbd58460cd 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PointInTimeReference.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PointInTimeReference.java @@ -66,12 +66,16 @@ public class PointInTimeReference implements JsonpSerializable { @Nullable private final Time keepAlive; + @Nullable + private final String routeSlice; + // --------------------------------------------------------------------------------------------- private PointInTimeReference(Builder builder) { this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); this.keepAlive = builder.keepAlive; + this.routeSlice = builder.routeSlice; } @@ -94,6 +98,18 @@ public final Time keepAlive() { return this.keepAlive; } + /** + * The slice identifiers to search within the point in time: a single slice, a + * comma-separated list such as tenant-a,tenant-b, or + * _all to search all slices. + *

+ * API name: {@code _slice} + */ + @Nullable + public final String routeSlice() { + return this.routeSlice; + } + /** * Serialize this object to JSON. */ @@ -113,6 +129,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.keepAlive.serialize(generator, mapper); } + if (this.routeSlice != null) { + generator.writeKey("_slice"); + generator.write(this.routeSlice); + + } } @@ -135,11 +156,15 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Time keepAlive; + @Nullable + private String routeSlice; + public Builder() { } private Builder(PointInTimeReference instance) { this.id = instance.id; this.keepAlive = instance.keepAlive; + this.routeSlice = instance.routeSlice; } /** @@ -165,6 +190,18 @@ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } + /** + * The slice identifiers to search within the point in time: a single slice, a + * comma-separated list such as tenant-a,tenant-b, or + * _all to search all slices. + *

+ * API name: {@code _slice} + */ + public final Builder routeSlice(@Nullable String value) { + this.routeSlice = value; + return this; + } + @Override protected Builder self() { return this; @@ -201,6 +238,7 @@ protected static void setupPointInTimeReferenceDeserializer(ObjectDeserializer

implement private Long createWeightCount; + private Long intoBitSet; + + private Long intoBitSetCount; + private Long match; private Long matchCount; @@ -408,6 +438,8 @@ private Builder(QueryBreakdown instance) { this.buildScorerCount = instance.buildScorerCount; this.createWeight = instance.createWeight; this.createWeightCount = instance.createWeightCount; + this.intoBitSet = instance.intoBitSet; + this.intoBitSetCount = instance.intoBitSetCount; this.match = instance.match; this.matchCount = instance.matchCount; this.shallowAdvance = instance.shallowAdvance; @@ -472,6 +504,22 @@ public final Builder createWeightCount(long value) { return this; } + /** + * Required - API name: {@code into_bit_set} + */ + public final Builder intoBitSet(long value) { + this.intoBitSet = value; + return this; + } + + /** + * Required - API name: {@code into_bit_set_count} + */ + public final Builder intoBitSetCount(long value) { + this.intoBitSetCount = value; + return this; + } + /** * Required - API name: {@code match} */ @@ -624,6 +672,8 @@ protected static void setupQueryBreakdownDeserializer(ObjectDeserializer debug; + private final List children; // --------------------------------------------------------------------------------------------- @@ -80,6 +84,7 @@ private QueryProfile(Builder builder) { this.description = ApiTypeHelper.requireNonNull(builder.description, this, "description"); this.timeInNanos = ApiTypeHelper.requireNonNull(builder.timeInNanos, this, "timeInNanos", 0); this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.debug = ApiTypeHelper.unmodifiable(builder.debug); this.children = ApiTypeHelper.unmodifiable(builder.children); } @@ -116,6 +121,18 @@ public final String type() { return this.type; } + /** + * Extra details about the query. + *

+ * Queries run by a rescorer include a rescorer key with the + * position of that rescorer in the shard's rescore array. + *

+ * API name: {@code debug} + */ + public final Map debug() { + return this.debug; + } + /** * API name: {@code children} */ @@ -146,6 +163,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("type"); generator.write(this.type); + if (ApiTypeHelper.isDefined(this.debug)) { + generator.writeKey("debug"); + generator.writeStartObject(); + for (Map.Entry item0 : this.debug.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } if (ApiTypeHelper.isDefined(this.children)) { generator.writeKey("children"); generator.writeStartArray(); @@ -179,6 +207,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement private String type; + @Nullable + private Map debug; + @Nullable private List children; @@ -189,6 +220,7 @@ private Builder(QueryProfile instance) { this.description = instance.description; this.timeInNanos = instance.timeInNanos; this.type = instance.type; + this.debug = instance.debug; this.children = instance.children; } @@ -231,6 +263,36 @@ public final Builder type(String value) { return this; } + /** + * Extra details about the query. + *

+ * Queries run by a rescorer include a rescorer key with the + * position of that rescorer in the shard's rescore array. + *

+ * API name: {@code debug} + *

+ * Adds all entries of map to debug. + */ + public final Builder debug(Map map) { + this.debug = _mapPutAll(this.debug, map); + return this; + } + + /** + * Extra details about the query. + *

+ * Queries run by a rescorer include a rescorer key with the + * position of that rescorer in the shard's rescore array. + *

+ * API name: {@code debug} + *

+ * Adds an entry to debug. + */ + public final Builder debug(String key, JsonData value) { + this.debug = _mapPut(this.debug, key, value); + return this; + } + /** * API name: {@code children} *

@@ -298,6 +360,7 @@ protected static void setupQueryProfileDeserializer(ObjectDeserializerAPI + * specification + */ +@JsonpDeserializable +public class QueryRescoreProfile extends RescoreProfileBase implements RescoreProfileVariant { + private final EmptyObject breakdown; + + // --------------------------------------------------------------------------------------------- + + private QueryRescoreProfile(Builder builder) { + super(builder); + + this.breakdown = ApiTypeHelper.requireNonNull(builder.breakdown, this, "breakdown"); + + } + + public static QueryRescoreProfile of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * RescoreProfile variant kind. + */ + @Override + public RescoreProfile.Kind _rescoreProfileKind() { + return RescoreProfile.Kind.Query; + } + + /** + * Required - The query rescorer does not report any steps. + *

+ * API name: {@code breakdown} + */ + public final EmptyObject breakdown() { + return this.breakdown; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "query"); + super.serializeInternal(generator, mapper); + generator.writeKey("breakdown"); + this.breakdown.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link QueryRescoreProfile}. + */ + + public static class Builder extends RescoreProfileBase.AbstractBuilder + implements + ObjectBuilder { + private EmptyObject breakdown; + + public Builder() { + } + private Builder(QueryRescoreProfile instance) { + this.breakdown = instance.breakdown; + + } + /** + * Required - The query rescorer does not report any steps. + *

+ * API name: {@code breakdown} + */ + public final Builder breakdown(EmptyObject value) { + this.breakdown = value; + return this; + } + + /** + * Required - The query rescorer does not report any steps. + *

+ * API name: {@code breakdown} + */ + public final Builder breakdown(Function> fn) { + return this.breakdown(fn.apply(new EmptyObject.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link QueryRescoreProfile}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public QueryRescoreProfile build() { + _checkSingleUse(); + + return new QueryRescoreProfile(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link QueryRescoreProfile} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, QueryRescoreProfile::setupQueryRescoreProfileDeserializer); + + protected static void setupQueryRescoreProfileDeserializer(ObjectDeserializer op) { + RescoreProfileBase.setupRescoreProfileBaseDeserializer(op); + op.add(Builder::breakdown, EmptyObject._DESERIALIZER, "breakdown"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfile.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfile.java new file mode 100644 index 0000000000..5ddb8faa9f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfile.java @@ -0,0 +1,323 @@ +/* + * 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.core.search; + +import co.elastic.clients.json.JsonData; +import co.elastic.clients.json.JsonEnum; +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.JsonpUtils; +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.OpenTaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Object; +import java.util.Objects; +import java.util.function.Function; +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: _global.search._types.RescoreProfile + +/** + * Profile of a single rescorer. + *

+ * The shape of breakdown depends on the type of rescorer: + * query and script do not report any steps, + * learning_to_rank does. + * + * @see API + * specification + */ +@JsonpDeserializable +public class RescoreProfile implements OpenTaggedUnion, JsonpSerializable { + + /** + * {@link RescoreProfile} variant kinds. + * + * @see API + * specification + */ + + public enum Kind implements JsonEnum { + LearningToRank("learning_to_rank"), + + Query("query"), + + Script("script"), + + /** A custom {@code RescoreProfile} defined by a plugin */ + _Custom(null) + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + public RescoreProfile(RescoreProfileVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._rescoreProfileKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + this._customKind = null; + + } + + private RescoreProfile(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + this._customKind = builder._customKind; + + } + + public static RescoreProfile of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Build a custom plugin-defined {@code RescoreProfile}, given its kind and some + * JSON data + */ + public RescoreProfile(String kind, JsonData value) { + this._kind = Kind._Custom; + this._value = value; + this._customKind = kind; + } + + /** + * Is this variant instance of kind {@code learning_to_rank}? + */ + public boolean isLearningToRank() { + return _kind == Kind.LearningToRank; + } + + /** + * Get the {@code learning_to_rank} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code learning_to_rank} + * kind. + */ + public LearningToRankRescoreProfile learningToRank() { + return TaggedUnionUtils.get(this, Kind.LearningToRank); + } + + /** + * Is this variant instance of kind {@code query}? + */ + public boolean isQuery() { + return _kind == Kind.Query; + } + + /** + * Get the {@code query} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code query} kind. + */ + public QueryRescoreProfile query() { + return TaggedUnionUtils.get(this, Kind.Query); + } + + /** + * Is this variant instance of kind {@code script}? + */ + public boolean isScript() { + return _kind == Kind.Script; + } + + /** + * Get the {@code script} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code script} kind. + */ + public ScriptRescoreProfile script() { + return TaggedUnionUtils.get(this, Kind.Script); + } + + @Nullable + private final String _customKind; + + /** + * Is this a custom {@code RescoreProfile} defined by a plugin? + */ + public boolean _isCustom() { + return _kind == Kind._Custom; + } + + /** + * Get the actual kind when {@code _kind()} equals {@link Kind#_Custom} + * (plugin-defined variant). + */ + @Nullable + public final String _customKind() { + return _customKind; + } + + /** + * Get the custom plugin-defined variant value. + * + * @throws IllegalStateException + * if the current variant is not {@link Kind#_Custom}. + */ + public JsonData _custom() { + return TaggedUnionUtils.get(this, Kind._Custom); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + + mapper.serialize(_value, generator); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + private String _customKind; + + @Override + protected Builder self() { + return this; + } + public ObjectBuilder learningToRank(LearningToRankRescoreProfile v) { + this._kind = Kind.LearningToRank; + this._value = v; + return this; + } + + public ObjectBuilder learningToRank( + Function> fn) { + return this.learningToRank(fn.apply(new LearningToRankRescoreProfile.Builder()).build()); + } + + public ObjectBuilder query(QueryRescoreProfile v) { + this._kind = Kind.Query; + this._value = v; + return this; + } + + public ObjectBuilder query( + Function> fn) { + return this.query(fn.apply(new QueryRescoreProfile.Builder()).build()); + } + + public ObjectBuilder script(ScriptRescoreProfile v) { + this._kind = Kind.Script; + this._value = v; + return this; + } + + public ObjectBuilder script( + Function> fn) { + return this.script(fn.apply(new ScriptRescoreProfile.Builder()).build()); + } + + /** + * Define this {@code RescoreProfile} as a plugin-defined variant. + * + * @param name + * the plugin-defined identifier + * @param data + * the data for this custom {@code RescoreProfile}. It is converted + * internally to {@link JsonData}. + */ + public ObjectBuilder _custom(String name, Object data) { + this._kind = Kind._Custom; + this._customKind = name; + this._value = JsonData.of(data); + return this; + } + + public RescoreProfile build() { + _checkSingleUse(); + return new RescoreProfile(this); + } + + } + + protected static void setupRescoreProfileDeserializer(ObjectDeserializer op) { + + op.add(Builder::learningToRank, LearningToRankRescoreProfile._DESERIALIZER, "learning_to_rank"); + op.add(Builder::query, QueryRescoreProfile._DESERIALIZER, "query"); + op.add(Builder::script, ScriptRescoreProfile._DESERIALIZER, "script"); + + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + JsonpUtils.ensureCustomVariantsAllowed(parser, mapper); + builder._custom(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); + + op.setTypeProperty("type", null); + + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + RescoreProfile::setupRescoreProfileDeserializer, Builder::build); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfileBase.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfileBase.java new file mode 100644 index 0000000000..c3cd03e22d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfileBase.java @@ -0,0 +1,276 @@ +/* + * 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.core.search; + +import co.elastic.clients.elasticsearch._types.Time; +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.JsonpUtils; +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.Map; +import java.util.Objects; +import java.util.function.Function; +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: _global.search._types.RescoreProfileBase + +/** + * + * @see API + * specification + */ + +public abstract class RescoreProfileBase implements JsonpSerializable { + private final String description; + + private final long timeInNanos; + + @Nullable + private final Time time; + + private final Map debug; + + // --------------------------------------------------------------------------------------------- + + protected RescoreProfileBase(AbstractBuilder builder) { + + this.description = ApiTypeHelper.requireNonNull(builder.description, this, "description"); + this.timeInNanos = ApiTypeHelper.requireNonNull(builder.timeInNanos, this, "timeInNanos", 0); + this.time = builder.time; + this.debug = ApiTypeHelper.unmodifiable(builder.debug); + + } + + /** + * Required - What the rescorer runs. + *

+ * API name: {@code description} + */ + public final String description() { + return this.description; + } + + /** + * Required - The total time spent in the rescorer, including the time spent + * running its queries. + *

+ * API name: {@code time_in_nanos} + */ + public final long timeInNanos() { + return this.timeInNanos; + } + + /** + * The time spent in the rescorer, in human-readable units. Only returned when + * human is true. + *

+ * API name: {@code time} + */ + @Nullable + public final Time time() { + return this.time; + } + + /** + * Extra details about the rescorer. + *

+ * Every rescorer reports window_size, the number of top documents + * it was configured to rescore. timed_out is set to + * true if the search timed out while the rescorer was running. + * Rescorers can add their own keys. + *

+ * API name: {@code debug} + */ + public final Map debug() { + return this.debug; + } + + /** + * 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("description"); + generator.write(this.description); + + generator.writeKey("time_in_nanos"); + generator.write(this.timeInNanos); + + if (this.time != null) { + generator.writeKey("time"); + this.time.serialize(generator, mapper); + + } + if (ApiTypeHelper.isDefined(this.debug)) { + generator.writeKey("debug"); + generator.writeStartObject(); + for (Map.Entry item0 : this.debug.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + private String description; + + private Long timeInNanos; + + @Nullable + private Time time; + + @Nullable + private Map debug; + + /** + * Required - What the rescorer runs. + *

+ * API name: {@code description} + */ + public final BuilderT description(String value) { + this.description = value; + return self(); + } + + /** + * Required - The total time spent in the rescorer, including the time spent + * running its queries. + *

+ * API name: {@code time_in_nanos} + */ + public final BuilderT timeInNanos(long value) { + this.timeInNanos = value; + return self(); + } + + /** + * The time spent in the rescorer, in human-readable units. Only returned when + * human is true. + *

+ * API name: {@code time} + */ + public final BuilderT time(@Nullable Time value) { + this.time = value; + return self(); + } + + /** + * The time spent in the rescorer, in human-readable units. Only returned when + * human is true. + *

+ * API name: {@code time} + */ + public final BuilderT time(Function> fn) { + return this.time(fn.apply(new Time.Builder()).build()); + } + + /** + * Extra details about the rescorer. + *

+ * Every rescorer reports window_size, the number of top documents + * it was configured to rescore. timed_out is set to + * true if the search timed out while the rescorer was running. + * Rescorers can add their own keys. + *

+ * API name: {@code debug} + *

+ * Adds all entries of map to debug. + */ + public final BuilderT debug(Map map) { + this.debug = _mapPutAll(this.debug, map); + return self(); + } + + /** + * Extra details about the rescorer. + *

+ * Every rescorer reports window_size, the number of top documents + * it was configured to rescore. timed_out is set to + * true if the search timed out while the rescorer was running. + * Rescorers can add their own keys. + *

+ * API name: {@code debug} + *

+ * Adds an entry to debug. + */ + public final BuilderT debug(String key, JsonData value) { + this.debug = _mapPut(this.debug, key, value); + return self(); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupRescoreProfileBaseDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::description, JsonpDeserializer.stringDeserializer(), "description"); + op.add(AbstractBuilder::timeInNanos, JsonpDeserializer.longDeserializer(), "time_in_nanos"); + op.add(AbstractBuilder::time, Time._DESERIALIZER, "time"); + op.add(AbstractBuilder::debug, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "debug"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfileBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfileBuilders.java new file mode 100644 index 0000000000..3810e86b47 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfileBuilders.java @@ -0,0 +1,103 @@ +/* + * 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.core.search; + +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link RescoreProfile} variants. + */ +public class RescoreProfileBuilders { + private RescoreProfileBuilders() { + } + + /** + * Creates a builder for the {@link LearningToRankRescoreProfile + * learning_to_rank} {@code RescoreProfile} variant. + */ + public static LearningToRankRescoreProfile.Builder learningToRank() { + return new LearningToRankRescoreProfile.Builder(); + } + + /** + * Creates a RescoreProfile of the {@link LearningToRankRescoreProfile + * learning_to_rank} {@code RescoreProfile} variant. + */ + public static RescoreProfile learningToRank( + Function> fn) { + RescoreProfile.Builder builder = new RescoreProfile.Builder(); + builder.learningToRank(fn.apply(new LearningToRankRescoreProfile.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link QueryRescoreProfile query} + * {@code RescoreProfile} variant. + */ + public static QueryRescoreProfile.Builder query() { + return new QueryRescoreProfile.Builder(); + } + + /** + * Creates a RescoreProfile of the {@link QueryRescoreProfile query} + * {@code RescoreProfile} variant. + */ + public static RescoreProfile query(Function> fn) { + RescoreProfile.Builder builder = new RescoreProfile.Builder(); + builder.query(fn.apply(new QueryRescoreProfile.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link ScriptRescoreProfile script} + * {@code RescoreProfile} variant. + */ + public static ScriptRescoreProfile.Builder script() { + return new ScriptRescoreProfile.Builder(); + } + + /** + * Creates a RescoreProfile of the {@link ScriptRescoreProfile script} + * {@code RescoreProfile} variant. + */ + public static RescoreProfile script( + Function> fn) { + RescoreProfile.Builder builder = new RescoreProfile.Builder(); + builder.script(fn.apply(new ScriptRescoreProfile.Builder()).build()); + return builder.build(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfileVariant.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfileVariant.java new file mode 100644 index 0000000000..25991a870e --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/RescoreProfileVariant.java @@ -0,0 +1,50 @@ +/* + * 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.core.search; + +import co.elastic.clients.json.JsonpSerializable; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Base interface for {@link RescoreProfile} variants. + */ +public interface RescoreProfileVariant extends JsonpSerializable { + + RescoreProfile.Kind _rescoreProfileKind(); + + default RescoreProfile _toRescoreProfile() { + return new RescoreProfile(this); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/ScriptRescoreProfile.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/ScriptRescoreProfile.java new file mode 100644 index 0000000000..70f301f550 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/ScriptRescoreProfile.java @@ -0,0 +1,176 @@ +/* + * 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.core.search; + +import co.elastic.clients.elasticsearch._types.EmptyObject; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +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 jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +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: _global.search._types.ScriptRescoreProfile + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ScriptRescoreProfile extends RescoreProfileBase implements RescoreProfileVariant { + private final EmptyObject breakdown; + + // --------------------------------------------------------------------------------------------- + + private ScriptRescoreProfile(Builder builder) { + super(builder); + + this.breakdown = ApiTypeHelper.requireNonNull(builder.breakdown, this, "breakdown"); + + } + + public static ScriptRescoreProfile of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * RescoreProfile variant kind. + */ + @Override + public RescoreProfile.Kind _rescoreProfileKind() { + return RescoreProfile.Kind.Script; + } + + /** + * Required - The script rescorer does not report any steps. + *

+ * API name: {@code breakdown} + */ + public final EmptyObject breakdown() { + return this.breakdown; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "script"); + super.serializeInternal(generator, mapper); + generator.writeKey("breakdown"); + this.breakdown.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ScriptRescoreProfile}. + */ + + public static class Builder extends RescoreProfileBase.AbstractBuilder + implements + ObjectBuilder { + private EmptyObject breakdown; + + public Builder() { + } + private Builder(ScriptRescoreProfile instance) { + this.breakdown = instance.breakdown; + + } + /** + * Required - The script rescorer does not report any steps. + *

+ * API name: {@code breakdown} + */ + public final Builder breakdown(EmptyObject value) { + this.breakdown = value; + return this; + } + + /** + * Required - The script rescorer does not report any steps. + *

+ * API name: {@code breakdown} + */ + public final Builder breakdown(Function> fn) { + return this.breakdown(fn.apply(new EmptyObject.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ScriptRescoreProfile}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ScriptRescoreProfile build() { + _checkSingleUse(); + + return new ScriptRescoreProfile(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ScriptRescoreProfile} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ScriptRescoreProfile::setupScriptRescoreProfileDeserializer); + + protected static void setupScriptRescoreProfileDeserializer(ObjectDeserializer op) { + RescoreProfileBase.setupRescoreProfileBaseDeserializer(op); + op.add(Builder::breakdown, EmptyObject._DESERIALIZER, "breakdown"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/ShardProfile.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/ShardProfile.java index e65445d8fe..1c1407576b 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/ShardProfile.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/ShardProfile.java @@ -78,6 +78,8 @@ public class ShardProfile implements JsonpSerializable { private final String nodeId; + private final List rescore; + private final List searches; private final int shardId; @@ -93,6 +95,7 @@ private ShardProfile(Builder builder) { this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.nodeId = ApiTypeHelper.requireNonNull(builder.nodeId, this, "nodeId"); + this.rescore = ApiTypeHelper.unmodifiable(builder.rescore); this.searches = ApiTypeHelper.unmodifiableRequired(builder.searches, this, "searches"); this.shardId = ApiTypeHelper.requireNonNull(builder.shardId, this, "shardId", 0); @@ -153,6 +156,16 @@ public final String nodeId() { return this.nodeId; } + /** + * One entry per rescorer, in the order they ran. Omitted when the request has + * no rescorer. + *

+ * API name: {@code rescore} + */ + public final List rescore() { + return this.rescore; + } + /** * Required - API name: {@code searches} */ @@ -210,6 +223,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("node_id"); generator.write(this.nodeId); + if (ApiTypeHelper.isDefined(this.rescore)) { + generator.writeKey("rescore"); + generator.writeStartArray(); + for (RescoreProfile item0 : this.rescore) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } if (ApiTypeHelper.isDefined(this.searches)) { generator.writeKey("searches"); generator.writeStartArray(); @@ -253,6 +276,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement private String nodeId; + @Nullable + private List rescore; + private List searches; private Integer shardId; @@ -267,6 +293,7 @@ private Builder(ShardProfile instance) { this.id = instance.id; this.index = instance.index; this.nodeId = instance.nodeId; + this.rescore = instance.rescore; this.searches = instance.searches; this.shardId = instance.shardId; @@ -362,6 +389,44 @@ public final Builder nodeId(String value) { return this; } + /** + * One entry per rescorer, in the order they ran. Omitted when the request has + * no rescorer. + *

+ * API name: {@code rescore} + *

+ * Adds all elements of list to rescore. + */ + public final Builder rescore(List list) { + this.rescore = _listAddAll(this.rescore, list); + return this; + } + + /** + * One entry per rescorer, in the order they ran. Omitted when the request has + * no rescorer. + *

+ * API name: {@code rescore} + *

+ * Adds one or more values to rescore. + */ + public final Builder rescore(RescoreProfile value, RescoreProfile... values) { + this.rescore = _listAdd(this.rescore, value, values); + return this; + } + + /** + * One entry per rescorer, in the order they ran. Omitted when the request has + * no rescorer. + *

+ * API name: {@code rescore} + *

+ * Adds a value to rescore using a builder lambda. + */ + public final Builder rescore(Function> fn) { + return rescore(fn.apply(new RescoreProfile.Builder()).build()); + } + /** * Required - API name: {@code searches} *

@@ -441,6 +506,7 @@ protected static void setupShardProfileDeserializer(ObjectDeserializer + * Get the status and details of a recovery that was started with the start + * recovery API. This API is intended for internal operator use. The progress of + * a running recovery is reported as a percentage, and the repository and audit + * details of the recovery are not exposed. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture getRecovery(GetRecoveryRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) GetRecoveryRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Get a recovery. + *

+ * Get the status and details of a recovery that was started with the start + * recovery API. This API is intended for internal operator use. The progress of + * a running recovery is reported as a percentage, and the repository and audit + * details of the recovery are not exposed. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRecoveryRequest} + * @see Documentation on elastic.co + */ + + public final CompletableFuture getRecovery( + Function> fn) { + return getRecovery(fn.apply(new GetRecoveryRequest.Builder()).build()); + } + // ----- Endpoint: data_recovery.get_recovery_points /** @@ -122,4 +161,203 @@ public CompletableFuture getRecoveryPoints() { GetRecoveryPointsRequest._ENDPOINT, this.transportOptions); } + // ----- Endpoint: data_recovery.get_recovery_sources + + /** + * Get recovery sources. + *

+ * Get the logical sources captured at an exact recovery point in the + * platform-managed data recovery repository. This API is intended for internal + * operator use. Repository, snapshot, and policy identifiers are not exposed. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture getRecoverySources(GetRecoverySourcesRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) GetRecoverySourcesRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Get recovery sources. + *

+ * Get the logical sources captured at an exact recovery point in the + * platform-managed data recovery repository. This API is intended for internal + * operator use. Repository, snapshot, and policy identifiers are not exposed. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRecoverySourcesRequest} + * @see Documentation on elastic.co + */ + + public final CompletableFuture getRecoverySources( + Function> fn) { + return getRecoverySources(fn.apply(new GetRecoverySourcesRequest.Builder()).build()); + } + + // ----- Endpoint: data_recovery.get_rpo_series + + /** + * Get the recovery point objective series. + *

+ * Get, for each bucket in the half-open range [start, end), the + * maximum age that the newest recoverable state reached during that bucket. + * This API is intended for internal operator use. The range is divided into at + * most 1,000 buckets. A bucket has no value if no retained recovery point + * covers its start. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture getRpoSeries(GetRpoSeriesRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) GetRpoSeriesRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Get the recovery point objective series. + *

+ * Get, for each bucket in the half-open range [start, end), the + * maximum age that the newest recoverable state reached during that bucket. + * This API is intended for internal operator use. The range is divided into at + * most 1,000 buckets. A bucket has no value if no retained recovery point + * covers its start. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRpoSeriesRequest} + * @see Documentation on elastic.co + */ + + public final CompletableFuture getRpoSeries( + Function> fn) { + return getRpoSeries(fn.apply(new GetRpoSeriesRequest.Builder()).build()); + } + + /** + * Get the recovery point objective series. + *

+ * Get, for each bucket in the half-open range [start, end), the + * maximum age that the newest recoverable state reached during that bucket. + * This API is intended for internal operator use. The range is divided into at + * most 1,000 buckets. A bucket has no value if no retained recovery point + * covers its start. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture getRpoSeries() { + return this.transport.performRequestAsync(new GetRpoSeriesRequest.Builder().build(), + GetRpoSeriesRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: data_recovery.list_recoveries + + /** + * List recoveries. + *

+ * List the recoveries that were started with the start recovery API, including + * those that have finished. This API is intended for internal operator use. + * Recoveries are ordered by start time, and the most recent are returned first + * by default. To retrieve further pages, pass the start time and identifier of + * the last recovery of a page as search_after_started_at and + * search_after_recovery_id. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture listRecoveries(ListRecoveriesRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) ListRecoveriesRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * List recoveries. + *

+ * List the recoveries that were started with the start recovery API, including + * those that have finished. This API is intended for internal operator use. + * Recoveries are ordered by start time, and the most recent are returned first + * by default. To retrieve further pages, pass the start time and identifier of + * the last recovery of a page as search_after_started_at and + * search_after_recovery_id. + * + * @param fn + * a function that initializes a builder to create the + * {@link ListRecoveriesRequest} + * @see Documentation on elastic.co + */ + + public final CompletableFuture listRecoveries( + Function> fn) { + return listRecoveries(fn.apply(new ListRecoveriesRequest.Builder()).build()); + } + + /** + * List recoveries. + *

+ * List the recoveries that were started with the start recovery API, including + * those that have finished. This API is intended for internal operator use. + * Recoveries are ordered by start time, and the most recent are returned first + * by default. To retrieve further pages, pass the start time and identifier of + * the last recovery of a page as search_after_started_at and + * search_after_recovery_id. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture listRecoveries() { + return this.transport.performRequestAsync(new ListRecoveriesRequest.Builder().build(), + ListRecoveriesRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: data_recovery.start_recovery + + /** + * Start a recovery. + *

+ * Start recovering indices and data streams from a recovery point. This API is + * intended for internal operator use. Depending on the mode, the sources are + * either replaced with their state at the recovery point, over the data that + * currently exists, or recovered under new names. The recovery runs in the + * background, so the API returns with a 202 Accepted status once + * it has started. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture startRecovery(StartRecoveryRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) StartRecoveryRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Start a recovery. + *

+ * Start recovering indices and data streams from a recovery point. This API is + * intended for internal operator use. Depending on the mode, the sources are + * either replaced with their state at the recovery point, over the data that + * currently exists, or recovered under new names. The recovery runs in the + * background, so the API returns with a 202 Accepted status once + * it has started. + * + * @param fn + * a function that initializes a builder to create the + * {@link StartRecoveryRequest} + * @see Documentation on elastic.co + */ + + public final CompletableFuture startRecovery( + Function> fn) { + return startRecovery(fn.apply(new StartRecoveryRequest.Builder()).build()); + } + } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ElasticsearchDataRecoveryClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ElasticsearchDataRecoveryClient.java index ac5310a608..78914902c6 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ElasticsearchDataRecoveryClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ElasticsearchDataRecoveryClient.java @@ -68,6 +68,46 @@ public ElasticsearchDataRecoveryClient withTransportOptions(@Nullable TransportO return new ElasticsearchDataRecoveryClient(this.transport, transportOptions); } + // ----- Endpoint: data_recovery.get_recovery + + /** + * Get a recovery. + *

+ * Get the status and details of a recovery that was started with the start + * recovery API. This API is intended for internal operator use. The progress of + * a running recovery is reported as a percentage, and the repository and audit + * details of the recovery are not exposed. + * + * @see Documentation on elastic.co + */ + + public GetRecoveryResponse getRecovery(GetRecoveryRequest request) throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) GetRecoveryRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Get a recovery. + *

+ * Get the status and details of a recovery that was started with the start + * recovery API. This API is intended for internal operator use. The progress of + * a running recovery is reported as a percentage, and the repository and audit + * details of the recovery are not exposed. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRecoveryRequest} + * @see Documentation on elastic.co + */ + + public final GetRecoveryResponse getRecovery( + Function> fn) + throws IOException, ElasticsearchException { + return getRecovery(fn.apply(new GetRecoveryRequest.Builder()).build()); + } + // ----- Endpoint: data_recovery.get_recovery_points /** @@ -125,4 +165,210 @@ public GetRecoveryPointsResponse getRecoveryPoints() throws IOException, Elastic GetRecoveryPointsRequest._ENDPOINT, this.transportOptions); } + // ----- Endpoint: data_recovery.get_recovery_sources + + /** + * Get recovery sources. + *

+ * Get the logical sources captured at an exact recovery point in the + * platform-managed data recovery repository. This API is intended for internal + * operator use. Repository, snapshot, and policy identifiers are not exposed. + * + * @see Documentation on elastic.co + */ + + public GetRecoverySourcesResponse getRecoverySources(GetRecoverySourcesRequest request) + throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) GetRecoverySourcesRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Get recovery sources. + *

+ * Get the logical sources captured at an exact recovery point in the + * platform-managed data recovery repository. This API is intended for internal + * operator use. Repository, snapshot, and policy identifiers are not exposed. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRecoverySourcesRequest} + * @see Documentation on elastic.co + */ + + public final GetRecoverySourcesResponse getRecoverySources( + Function> fn) + throws IOException, ElasticsearchException { + return getRecoverySources(fn.apply(new GetRecoverySourcesRequest.Builder()).build()); + } + + // ----- Endpoint: data_recovery.get_rpo_series + + /** + * Get the recovery point objective series. + *

+ * Get, for each bucket in the half-open range [start, end), the + * maximum age that the newest recoverable state reached during that bucket. + * This API is intended for internal operator use. The range is divided into at + * most 1,000 buckets. A bucket has no value if no retained recovery point + * covers its start. + * + * @see Documentation on elastic.co + */ + + public GetRpoSeriesResponse getRpoSeries(GetRpoSeriesRequest request) throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) GetRpoSeriesRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Get the recovery point objective series. + *

+ * Get, for each bucket in the half-open range [start, end), the + * maximum age that the newest recoverable state reached during that bucket. + * This API is intended for internal operator use. The range is divided into at + * most 1,000 buckets. A bucket has no value if no retained recovery point + * covers its start. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRpoSeriesRequest} + * @see Documentation on elastic.co + */ + + public final GetRpoSeriesResponse getRpoSeries( + Function> fn) + throws IOException, ElasticsearchException { + return getRpoSeries(fn.apply(new GetRpoSeriesRequest.Builder()).build()); + } + + /** + * Get the recovery point objective series. + *

+ * Get, for each bucket in the half-open range [start, end), the + * maximum age that the newest recoverable state reached during that bucket. + * This API is intended for internal operator use. The range is divided into at + * most 1,000 buckets. A bucket has no value if no retained recovery point + * covers its start. + * + * @see Documentation on elastic.co + */ + + public GetRpoSeriesResponse getRpoSeries() throws IOException, ElasticsearchException { + return this.transport.performRequest(new GetRpoSeriesRequest.Builder().build(), GetRpoSeriesRequest._ENDPOINT, + this.transportOptions); + } + + // ----- Endpoint: data_recovery.list_recoveries + + /** + * List recoveries. + *

+ * List the recoveries that were started with the start recovery API, including + * those that have finished. This API is intended for internal operator use. + * Recoveries are ordered by start time, and the most recent are returned first + * by default. To retrieve further pages, pass the start time and identifier of + * the last recovery of a page as search_after_started_at and + * search_after_recovery_id. + * + * @see Documentation on elastic.co + */ + + public ListRecoveriesResponse listRecoveries(ListRecoveriesRequest request) + throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) ListRecoveriesRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * List recoveries. + *

+ * List the recoveries that were started with the start recovery API, including + * those that have finished. This API is intended for internal operator use. + * Recoveries are ordered by start time, and the most recent are returned first + * by default. To retrieve further pages, pass the start time and identifier of + * the last recovery of a page as search_after_started_at and + * search_after_recovery_id. + * + * @param fn + * a function that initializes a builder to create the + * {@link ListRecoveriesRequest} + * @see Documentation on elastic.co + */ + + public final ListRecoveriesResponse listRecoveries( + Function> fn) + throws IOException, ElasticsearchException { + return listRecoveries(fn.apply(new ListRecoveriesRequest.Builder()).build()); + } + + /** + * List recoveries. + *

+ * List the recoveries that were started with the start recovery API, including + * those that have finished. This API is intended for internal operator use. + * Recoveries are ordered by start time, and the most recent are returned first + * by default. To retrieve further pages, pass the start time and identifier of + * the last recovery of a page as search_after_started_at and + * search_after_recovery_id. + * + * @see Documentation on elastic.co + */ + + public ListRecoveriesResponse listRecoveries() throws IOException, ElasticsearchException { + return this.transport.performRequest(new ListRecoveriesRequest.Builder().build(), + ListRecoveriesRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: data_recovery.start_recovery + + /** + * Start a recovery. + *

+ * Start recovering indices and data streams from a recovery point. This API is + * intended for internal operator use. Depending on the mode, the sources are + * either replaced with their state at the recovery point, over the data that + * currently exists, or recovered under new names. The recovery runs in the + * background, so the API returns with a 202 Accepted status once + * it has started. + * + * @see Documentation on elastic.co + */ + + public StartRecoveryResponse startRecovery(StartRecoveryRequest request) + throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) StartRecoveryRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Start a recovery. + *

+ * Start recovering indices and data streams from a recovery point. This API is + * intended for internal operator use. Depending on the mode, the sources are + * either replaced with their state at the recovery point, over the data that + * currently exists, or recovered under new names. The recovery runs in the + * background, so the API returns with a 202 Accepted status once + * it has started. + * + * @param fn + * a function that initializes a builder to create the + * {@link StartRecoveryRequest} + * @see Documentation on elastic.co + */ + + public final StartRecoveryResponse startRecovery( + Function> fn) + throws IOException, ElasticsearchException { + return startRecovery(fn.apply(new StartRecoveryRequest.Builder()).build()); + } + } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsRequest.java index 58407f2706..7adbb4201f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsRequest.java @@ -106,8 +106,9 @@ public final DateTime endTimeBefore() { } /** - * The 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. + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. *

* API name: {@code master_timeout} */ @@ -166,8 +167,9 @@ public final Builder endTimeBefore(@Nullable DateTime value) { } /** - * The 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. + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. *

* API name: {@code master_timeout} */ @@ -177,8 +179,9 @@ public final Builder masterTimeout(@Nullable Time value) { } /** - * The 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. + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. *

* API name: {@code master_timeout} */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsResponse.java index 4f9e7185c3..62540e6256 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsResponse.java @@ -19,7 +19,6 @@ package co.elastic.clients.elasticsearch.data_recovery; -import co.elastic.clients.elasticsearch.data_recovery.get_recovery_points.RecoveryPoint; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -61,7 +60,7 @@ */ @JsonpDeserializable public class GetRecoveryPointsResponse implements JsonpSerializable { - private final List recoveryPoints; + private final List recoveryPoints; // --------------------------------------------------------------------------------------------- @@ -80,7 +79,7 @@ public static GetRecoveryPointsResponse of(Function * API name: {@code recovery_points} */ - public final List recoveryPoints() { + public final List recoveryPoints() { return this.recoveryPoints; } @@ -98,7 +97,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.recoveryPoints)) { generator.writeKey("recovery_points"); generator.writeStartArray(); - for (RecoveryPoint item0 : this.recoveryPoints) { + for (Point item0 : this.recoveryPoints) { item0.serialize(generator, mapper); } @@ -122,7 +121,7 @@ public String toString() { public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { - private List recoveryPoints; + private List recoveryPoints; /** * Required - Recovery points in descending order by end time. @@ -131,7 +130,7 @@ public static class Builder extends WithJsonObjectBuilderBase *

* Adds all elements of list to recoveryPoints. */ - public final Builder recoveryPoints(List list) { + public final Builder recoveryPoints(List list) { this.recoveryPoints = _listAddAll(this.recoveryPoints, list); return this; } @@ -143,7 +142,7 @@ public final Builder recoveryPoints(List list) { *

* Adds one or more values to recoveryPoints. */ - public final Builder recoveryPoints(RecoveryPoint value, RecoveryPoint... values) { + public final Builder recoveryPoints(Point value, Point... values) { this.recoveryPoints = _listAdd(this.recoveryPoints, value, values); return this; } @@ -155,8 +154,8 @@ public final Builder recoveryPoints(RecoveryPoint value, RecoveryPoint... values *

* Adds a value to recoveryPoints using a builder lambda. */ - public final Builder recoveryPoints(Function> fn) { - return recoveryPoints(fn.apply(new RecoveryPoint.Builder()).build()); + public final Builder recoveryPoints(Function> fn) { + return recoveryPoints(fn.apply(new Point.Builder()).build()); } @Override @@ -188,8 +187,7 @@ public GetRecoveryPointsResponse build() { protected static void setupGetRecoveryPointsResponseDeserializer( ObjectDeserializer op) { - op.add(Builder::recoveryPoints, JsonpDeserializer.arrayDeserializer(RecoveryPoint._DESERIALIZER), - "recovery_points"); + op.add(Builder::recoveryPoints, JsonpDeserializer.arrayDeserializer(Point._DESERIALIZER), "recovery_points"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryRequest.java new file mode 100644 index 0000000000..65cd2b3fe1 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryRequest.java @@ -0,0 +1,202 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.RequestBase; +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.String; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery.get_recovery.Request + +/** + * Get a recovery. + *

+ * Get the status and details of a recovery that was started with the start + * recovery API. This API is intended for internal operator use. The progress of + * a running recovery is reported as a percentage, and the repository and audit + * details of the recovery are not exposed. + * + * @see API + * specification + */ + +public class GetRecoveryRequest extends RequestBase { + private final String recoveryId; + + // --------------------------------------------------------------------------------------------- + + private GetRecoveryRequest(Builder builder) { + + this.recoveryId = ApiTypeHelper.requireNonNull(builder.recoveryId, this, "recoveryId"); + + } + + public static GetRecoveryRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The identifier of the recovery, as returned when the recovery was + * started. + *

+ * API name: {@code recovery_id} + */ + public final String recoveryId() { + return this.recoveryId; + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GetRecoveryRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + private String recoveryId; + + public Builder() { + } + private Builder(GetRecoveryRequest instance) { + this.recoveryId = instance.recoveryId; + + } + /** + * Required - The identifier of the recovery, as returned when the recovery was + * started. + *

+ * API name: {@code recovery_id} + */ + public final Builder recoveryId(String value) { + this.recoveryId = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GetRecoveryRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GetRecoveryRequest build() { + _checkSingleUse(); + + return new GetRecoveryRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code data_recovery.get_recovery}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/data_recovery.get_recovery", + + // Request method + request -> { + return "GET"; + + }, + + // Request path + request -> { + final int _recoveryId = 1 << 0; + + int propsSet = 0; + + propsSet |= _recoveryId; + + if (propsSet == (_recoveryId)) { + StringBuilder buf = new StringBuilder(); + buf.append("/_data_recovery"); + buf.append("/recoveries"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.recoveryId, buf); + return buf.toString(); + } + throw SimpleEndpoint.noPathTemplateFound("path"); + + }, + + // Path parameters + request -> { + Map params = new HashMap<>(); + final int _recoveryId = 1 << 0; + + int propsSet = 0; + + propsSet |= _recoveryId; + + if (propsSet == (_recoveryId)) { + params.put("recoveryId", request.recoveryId); + } + return params; + }, + + // Request parameters + request -> { + return Collections.emptyMap(); + + }, SimpleEndpoint.emptyMap(), false, GetRecoveryResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryResponse.java new file mode 100644 index 0000000000..535774b55a --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryResponse.java @@ -0,0 +1,107 @@ +/* + * 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.data_recovery; + +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.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: data_recovery.get_recovery.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class GetRecoveryResponse extends Recovery { + // --------------------------------------------------------------------------------------------- + + private GetRecoveryResponse(Builder builder) { + super(builder); + + } + + public static GetRecoveryResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GetRecoveryResponse}. + */ + + public static class Builder extends Recovery.AbstractBuilder + implements + ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GetRecoveryResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GetRecoveryResponse build() { + _checkSingleUse(); + + return new GetRecoveryResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GetRecoveryResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, GetRecoveryResponse::setupGetRecoveryResponseDeserializer); + + protected static void setupGetRecoveryResponseDeserializer(ObjectDeserializer op) { + Recovery.setupRecoveryDeserializer(op); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoverySourcesRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoverySourcesRequest.java new file mode 100644 index 0000000000..9d27241906 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoverySourcesRequest.java @@ -0,0 +1,340 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +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.DateTime; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.Integer; +import java.lang.String; +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: data_recovery.get_recovery_sources.Request + +/** + * Get recovery sources. + *

+ * Get the logical sources captured at an exact recovery point in the + * platform-managed data recovery repository. This API is intended for internal + * operator use. Repository, snapshot, and policy identifiers are not exposed. + * + * @see API + * specification + */ + +public class GetRecoverySourcesRequest extends RequestBase { + private final List expression; + + @Nullable + private final Boolean includeIncompleteSources; + + @Nullable + private final Time masterTimeout; + + private final DateTime recoveryPointEndTime; + + @Nullable + private final Integer size; + + // --------------------------------------------------------------------------------------------- + + private GetRecoverySourcesRequest(Builder builder) { + + this.expression = ApiTypeHelper.unmodifiableRequired(builder.expression, this, "expression"); + this.includeIncompleteSources = builder.includeIncompleteSources; + this.masterTimeout = builder.masterTimeout; + this.recoveryPointEndTime = ApiTypeHelper.requireNonNull(builder.recoveryPointEndTime, this, + "recoveryPointEndTime"); + this.size = builder.size; + + } + + public static GetRecoverySourcesRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - A comma-separated list of source expressions to match. Wildcards + * and exclusions prefixed with - are supported. + *

+ * API name: {@code expression} + */ + public final List expression() { + return this.expression; + } + + /** + * If true, include logical sources that were not completely + * captured in the recovery point. + *

+ * API name: {@code include_incomplete_sources} + */ + @Nullable + public final Boolean includeIncompleteSources() { + return this.includeIncompleteSources; + } + + /** + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. + *

+ * API name: {@code master_timeout} + */ + @Nullable + public final Time masterTimeout() { + return this.masterTimeout; + } + + /** + * Required - The exact end time of the recovery point. + *

+ * API name: {@code recovery_point_end_time} + */ + public final DateTime recoveryPointEndTime() { + return this.recoveryPointEndTime; + } + + /** + * The maximum number of matching sources to return. The value must be between 1 + * and 1000. + *

+ * API name: {@code size} + */ + @Nullable + public final Integer size() { + return this.size; + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GetRecoverySourcesRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + private List expression; + + @Nullable + private Boolean includeIncompleteSources; + + @Nullable + private Time masterTimeout; + + private DateTime recoveryPointEndTime; + + @Nullable + private Integer size; + + public Builder() { + } + private Builder(GetRecoverySourcesRequest instance) { + this.expression = instance.expression; + this.includeIncompleteSources = instance.includeIncompleteSources; + this.masterTimeout = instance.masterTimeout; + this.recoveryPointEndTime = instance.recoveryPointEndTime; + this.size = instance.size; + + } + /** + * Required - A comma-separated list of source expressions to match. Wildcards + * and exclusions prefixed with - are supported. + *

+ * API name: {@code expression} + *

+ * Adds all elements of list to expression. + */ + public final Builder expression(List list) { + this.expression = _listAddAll(this.expression, list); + return this; + } + + /** + * Required - A comma-separated list of source expressions to match. Wildcards + * and exclusions prefixed with - are supported. + *

+ * API name: {@code expression} + *

+ * Adds one or more values to expression. + */ + public final Builder expression(String value, String... values) { + this.expression = _listAdd(this.expression, value, values); + return this; + } + + /** + * If true, include logical sources that were not completely + * captured in the recovery point. + *

+ * API name: {@code include_incomplete_sources} + */ + public final Builder includeIncompleteSources(@Nullable Boolean value) { + this.includeIncompleteSources = value; + return this; + } + + /** + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. + *

+ * API name: {@code master_timeout} + */ + public final Builder masterTimeout(@Nullable Time value) { + this.masterTimeout = value; + return this; + } + + /** + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. + *

+ * API name: {@code master_timeout} + */ + public final Builder masterTimeout(Function> fn) { + return this.masterTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Required - The exact end time of the recovery point. + *

+ * API name: {@code recovery_point_end_time} + */ + public final Builder recoveryPointEndTime(DateTime value) { + this.recoveryPointEndTime = value; + return this; + } + + /** + * The maximum number of matching sources to return. The value must be between 1 + * and 1000. + *

+ * API name: {@code size} + */ + public final Builder size(@Nullable Integer value) { + this.size = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GetRecoverySourcesRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GetRecoverySourcesRequest build() { + _checkSingleUse(); + + return new GetRecoverySourcesRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code data_recovery.get_recovery_sources}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/data_recovery.get_recovery_sources", + + // Request method + request -> { + return "GET"; + + }, + + // Request path + request -> { + return "/_data_recovery/sources"; + + }, + + // Path parameters + request -> { + return Collections.emptyMap(); + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } + params.put("expression", request.expression.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + if (request.includeIncompleteSources != null) { + params.put("include_incomplete_sources", String.valueOf(request.includeIncompleteSources)); + } + if (request.size != null) { + params.put("size", String.valueOf(request.size)); + } + params.put("recovery_point_end_time", request.recoveryPointEndTime.toString()); + return params; + + }, SimpleEndpoint.emptyMap(), false, GetRecoverySourcesResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoverySourcesResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoverySourcesResponse.java new file mode 100644 index 0000000000..58bc5ca27d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoverySourcesResponse.java @@ -0,0 +1,261 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.elasticsearch.data_recovery.get_recovery_sources.RecoverySource; +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.JsonpUtils; +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.util.List; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery.get_recovery_sources.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class GetRecoverySourcesResponse implements JsonpSerializable { + private final boolean hasMore; + + private final Point recoveryPoint; + + private final List sources; + + // --------------------------------------------------------------------------------------------- + + private GetRecoverySourcesResponse(Builder builder) { + + this.hasMore = ApiTypeHelper.requireNonNull(builder.hasMore, this, "hasMore", false); + this.recoveryPoint = ApiTypeHelper.requireNonNull(builder.recoveryPoint, this, "recoveryPoint"); + this.sources = ApiTypeHelper.unmodifiableRequired(builder.sources, this, "sources"); + + } + + public static GetRecoverySourcesResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - Whether more matching sources are available than were returned. + *

+ * API name: {@code has_more} + */ + public final boolean hasMore() { + return this.hasMore; + } + + /** + * Required - The selected recovery point. + *

+ * API name: {@code recovery_point} + */ + public final Point recoveryPoint() { + return this.recoveryPoint; + } + + /** + * Required - Matching logical recovery sources ordered by name. + *

+ * API name: {@code sources} + */ + public final List sources() { + return this.sources; + } + + /** + * 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("has_more"); + generator.write(this.hasMore); + + generator.writeKey("recovery_point"); + this.recoveryPoint.serialize(generator, mapper); + + if (ApiTypeHelper.isDefined(this.sources)) { + generator.writeKey("sources"); + generator.writeStartArray(); + for (RecoverySource item0 : this.sources) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GetRecoverySourcesResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Boolean hasMore; + + private Point recoveryPoint; + + private List sources; + + /** + * Required - Whether more matching sources are available than were returned. + *

+ * API name: {@code has_more} + */ + public final Builder hasMore(boolean value) { + this.hasMore = value; + return this; + } + + /** + * Required - The selected recovery point. + *

+ * API name: {@code recovery_point} + */ + public final Builder recoveryPoint(Point value) { + this.recoveryPoint = value; + return this; + } + + /** + * Required - The selected recovery point. + *

+ * API name: {@code recovery_point} + */ + public final Builder recoveryPoint(Function> fn) { + return this.recoveryPoint(fn.apply(new Point.Builder()).build()); + } + + /** + * Required - Matching logical recovery sources ordered by name. + *

+ * API name: {@code sources} + *

+ * Adds all elements of list to sources. + */ + public final Builder sources(List list) { + this.sources = _listAddAll(this.sources, list); + return this; + } + + /** + * Required - Matching logical recovery sources ordered by name. + *

+ * API name: {@code sources} + *

+ * Adds one or more values to sources. + */ + public final Builder sources(RecoverySource value, RecoverySource... values) { + this.sources = _listAdd(this.sources, value, values); + return this; + } + + /** + * Required - Matching logical recovery sources ordered by name. + *

+ * API name: {@code sources} + *

+ * Adds a value to sources using a builder lambda. + */ + public final Builder sources(Function> fn) { + return sources(fn.apply(new RecoverySource.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GetRecoverySourcesResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GetRecoverySourcesResponse build() { + _checkSingleUse(); + + return new GetRecoverySourcesResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GetRecoverySourcesResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, GetRecoverySourcesResponse::setupGetRecoverySourcesResponseDeserializer); + + protected static void setupGetRecoverySourcesResponseDeserializer( + ObjectDeserializer op) { + + op.add(Builder::hasMore, JsonpDeserializer.booleanDeserializer(), "has_more"); + op.add(Builder::recoveryPoint, Point._DESERIALIZER, "recovery_point"); + op.add(Builder::sources, JsonpDeserializer.arrayDeserializer(RecoverySource._DESERIALIZER), "sources"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRpoSeriesRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRpoSeriesRequest.java new file mode 100644 index 0000000000..acba67388d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRpoSeriesRequest.java @@ -0,0 +1,310 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +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.DateTime; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery.get_rpo_series.Request + +/** + * Get the recovery point objective series. + *

+ * Get, for each bucket in the half-open range [start, end), the + * maximum age that the newest recoverable state reached during that bucket. + * This API is intended for internal operator use. The range is divided into at + * most 1,000 buckets. A bucket has no value if no retained recovery point + * covers its start. + * + * @see API + * specification + */ + +public class GetRpoSeriesRequest extends RequestBase { + @Nullable + private final Time bucketDuration; + + @Nullable + private final DateTime end; + + @Nullable + private final Time masterTimeout; + + @Nullable + private final DateTime start; + + // --------------------------------------------------------------------------------------------- + + private GetRpoSeriesRequest(Builder builder) { + + this.bucketDuration = builder.bucketDuration; + this.end = builder.end; + this.masterTimeout = builder.masterTimeout; + this.start = builder.start; + + } + + public static GetRpoSeriesRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The duration of each bucket. It must be greater than zero, and the range must + * divide into at most 1,000 buckets. + *

+ * API name: {@code bucket_duration} + */ + @Nullable + public final Time bucketDuration() { + return this.bucketDuration; + } + + /** + * The exclusive end of the range, as a date or epoch milliseconds. + *

+ * API name: {@code end} + */ + @Nullable + public final DateTime end() { + return this.end; + } + + /** + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. + *

+ * API name: {@code master_timeout} + */ + @Nullable + public final Time masterTimeout() { + return this.masterTimeout; + } + + /** + * The inclusive start of the range, as a date or epoch milliseconds. When + * omitted, it is seven days before end, rounded down to a whole + * multiple of bucket_duration, so that repeated requests with + * default parameters return the same bucket boundaries. + *

+ * API name: {@code start} + */ + @Nullable + public final DateTime start() { + return this.start; + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GetRpoSeriesRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private Time bucketDuration; + + @Nullable + private DateTime end; + + @Nullable + private Time masterTimeout; + + @Nullable + private DateTime start; + + public Builder() { + } + private Builder(GetRpoSeriesRequest instance) { + this.bucketDuration = instance.bucketDuration; + this.end = instance.end; + this.masterTimeout = instance.masterTimeout; + this.start = instance.start; + + } + /** + * The duration of each bucket. It must be greater than zero, and the range must + * divide into at most 1,000 buckets. + *

+ * API name: {@code bucket_duration} + */ + public final Builder bucketDuration(@Nullable Time value) { + this.bucketDuration = value; + return this; + } + + /** + * The duration of each bucket. It must be greater than zero, and the range must + * divide into at most 1,000 buckets. + *

+ * API name: {@code bucket_duration} + */ + public final Builder bucketDuration(Function> fn) { + return this.bucketDuration(fn.apply(new Time.Builder()).build()); + } + + /** + * The exclusive end of the range, as a date or epoch milliseconds. + *

+ * API name: {@code end} + */ + public final Builder end(@Nullable DateTime value) { + this.end = value; + return this; + } + + /** + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. + *

+ * API name: {@code master_timeout} + */ + public final Builder masterTimeout(@Nullable Time value) { + this.masterTimeout = value; + return this; + } + + /** + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. + *

+ * API name: {@code master_timeout} + */ + public final Builder masterTimeout(Function> fn) { + return this.masterTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * The inclusive start of the range, as a date or epoch milliseconds. When + * omitted, it is seven days before end, rounded down to a whole + * multiple of bucket_duration, so that repeated requests with + * default parameters return the same bucket boundaries. + *

+ * API name: {@code start} + */ + public final Builder start(@Nullable DateTime value) { + this.start = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GetRpoSeriesRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GetRpoSeriesRequest build() { + _checkSingleUse(); + + return new GetRpoSeriesRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code data_recovery.get_rpo_series}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/data_recovery.get_rpo_series", + + // Request method + request -> { + return "GET"; + + }, + + // Request path + request -> { + return "/_data_recovery/rpo"; + + }, + + // Path parameters + request -> { + return Collections.emptyMap(); + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } + if (request.start != null) { + params.put("start", request.start.toString()); + } + if (request.end != null) { + params.put("end", request.end.toString()); + } + if (request.bucketDuration != null) { + params.put("bucket_duration", request.bucketDuration._toJsonString()); + } + return params; + + }, SimpleEndpoint.emptyMap(), false, GetRpoSeriesResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRpoSeriesResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRpoSeriesResponse.java new file mode 100644 index 0000000000..5d3dca5e9f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRpoSeriesResponse.java @@ -0,0 +1,316 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.elasticsearch._types.Time; +import co.elastic.clients.elasticsearch.data_recovery.get_rpo_series.RpoBucket; +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.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.DateTime; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Integer; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery.get_rpo_series.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class GetRpoSeriesResponse implements JsonpSerializable { + private final DateTime start; + + private final DateTime end; + + private final Time bucketDuration; + + private final int bucketCount; + + private final List buckets; + + // --------------------------------------------------------------------------------------------- + + private GetRpoSeriesResponse(Builder builder) { + + this.start = ApiTypeHelper.requireNonNull(builder.start, this, "start"); + this.end = ApiTypeHelper.requireNonNull(builder.end, this, "end"); + this.bucketDuration = ApiTypeHelper.requireNonNull(builder.bucketDuration, this, "bucketDuration"); + this.bucketCount = ApiTypeHelper.requireNonNull(builder.bucketCount, this, "bucketCount", 0); + this.buckets = ApiTypeHelper.unmodifiableRequired(builder.buckets, this, "buckets"); + + } + + public static GetRpoSeriesResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The inclusive start of the range. + *

+ * API name: {@code start} + */ + public final DateTime start() { + return this.start; + } + + /** + * Required - The exclusive end of the range. + *

+ * API name: {@code end} + */ + public final DateTime end() { + return this.end; + } + + /** + * Required - The duration of each bucket. + *

+ * API name: {@code bucket_duration} + */ + public final Time bucketDuration() { + return this.bucketDuration; + } + + /** + * Required - The number of buckets in the series. + *

+ * API name: {@code bucket_count} + */ + public final int bucketCount() { + return this.bucketCount; + } + + /** + * Required - The buckets in ascending order by start time. + *

+ * API name: {@code buckets} + */ + public final List buckets() { + return this.buckets; + } + + /** + * 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("start"); + this.start.serialize(generator, mapper); + generator.writeKey("end"); + this.end.serialize(generator, mapper); + generator.writeKey("bucket_duration"); + this.bucketDuration.serialize(generator, mapper); + + generator.writeKey("bucket_count"); + generator.write(this.bucketCount); + + if (ApiTypeHelper.isDefined(this.buckets)) { + generator.writeKey("buckets"); + generator.writeStartArray(); + for (RpoBucket item0 : this.buckets) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GetRpoSeriesResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private DateTime start; + + private DateTime end; + + private Time bucketDuration; + + private Integer bucketCount; + + private List buckets; + + /** + * Required - The inclusive start of the range. + *

+ * API name: {@code start} + */ + public final Builder start(DateTime value) { + this.start = value; + return this; + } + + /** + * Required - The exclusive end of the range. + *

+ * API name: {@code end} + */ + public final Builder end(DateTime value) { + this.end = value; + return this; + } + + /** + * Required - The duration of each bucket. + *

+ * API name: {@code bucket_duration} + */ + public final Builder bucketDuration(Time value) { + this.bucketDuration = value; + return this; + } + + /** + * Required - The duration of each bucket. + *

+ * API name: {@code bucket_duration} + */ + public final Builder bucketDuration(Function> fn) { + return this.bucketDuration(fn.apply(new Time.Builder()).build()); + } + + /** + * Required - The number of buckets in the series. + *

+ * API name: {@code bucket_count} + */ + public final Builder bucketCount(int value) { + this.bucketCount = value; + return this; + } + + /** + * Required - The buckets in ascending order by start time. + *

+ * API name: {@code buckets} + *

+ * Adds all elements of list to buckets. + */ + public final Builder buckets(List list) { + this.buckets = _listAddAll(this.buckets, list); + return this; + } + + /** + * Required - The buckets in ascending order by start time. + *

+ * API name: {@code buckets} + *

+ * Adds one or more values to buckets. + */ + public final Builder buckets(RpoBucket value, RpoBucket... values) { + this.buckets = _listAdd(this.buckets, value, values); + return this; + } + + /** + * Required - The buckets in ascending order by start time. + *

+ * API name: {@code buckets} + *

+ * Adds a value to buckets using a builder lambda. + */ + public final Builder buckets(Function> fn) { + return buckets(fn.apply(new RpoBucket.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GetRpoSeriesResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GetRpoSeriesResponse build() { + _checkSingleUse(); + + return new GetRpoSeriesResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GetRpoSeriesResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, GetRpoSeriesResponse::setupGetRpoSeriesResponseDeserializer); + + protected static void setupGetRpoSeriesResponseDeserializer(ObjectDeserializer op) { + + op.add(Builder::start, DateTime._DESERIALIZER, "start"); + op.add(Builder::end, DateTime._DESERIALIZER, "end"); + op.add(Builder::bucketDuration, Time._DESERIALIZER, "bucket_duration"); + op.add(Builder::bucketCount, JsonpDeserializer.integerDeserializer(), "bucket_count"); + op.add(Builder::buckets, JsonpDeserializer.arrayDeserializer(RpoBucket._DESERIALIZER), "buckets"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ListRecoveriesRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ListRecoveriesRequest.java new file mode 100644 index 0000000000..b5d792ca39 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ListRecoveriesRequest.java @@ -0,0 +1,406 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.RequestBase; +import co.elastic.clients.elasticsearch._types.SortOrder; +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.DateTime; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Integer; +import java.lang.String; +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: data_recovery.list_recoveries.Request + +/** + * List recoveries. + *

+ * List the recoveries that were started with the start recovery API, including + * those that have finished. This API is intended for internal operator use. + * Recoveries are ordered by start time, and the most recent are returned first + * by default. To retrieve further pages, pass the start time and identifier of + * the last recovery of a page as search_after_started_at and + * search_after_recovery_id. + * + * @see API + * specification + */ + +public class ListRecoveriesRequest extends RequestBase { + @Nullable + private final SortOrder order; + + @Nullable + private final String searchAfterRecoveryId; + + @Nullable + private final DateTime searchAfterStartedAt; + + @Nullable + private final Integer size; + + @Nullable + private final DateTime startedAtGte; + + @Nullable + private final DateTime startedAtLt; + + private final List status; + + // --------------------------------------------------------------------------------------------- + + private ListRecoveriesRequest(Builder builder) { + + this.order = builder.order; + this.searchAfterRecoveryId = builder.searchAfterRecoveryId; + this.searchAfterStartedAt = builder.searchAfterStartedAt; + this.size = builder.size; + this.startedAtGte = builder.startedAtGte; + this.startedAtLt = builder.startedAtLt; + this.status = ApiTypeHelper.unmodifiable(builder.status); + + } + + public static ListRecoveriesRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The order of the recoveries by start time. + *

+ * API name: {@code order} + */ + @Nullable + public final SortOrder order() { + return this.order; + } + + /** + * Return only recoveries after this identifier in the sort order for recoveries + * with the same start time, to retrieve the next page. It must be provided + * together with search_after_started_at. + *

+ * API name: {@code search_after_recovery_id} + */ + @Nullable + public final String searchAfterRecoveryId() { + return this.searchAfterRecoveryId; + } + + /** + * Return only recoveries after this start time in the sort order, to retrieve + * the next page. It must be provided together with + * search_after_recovery_id. + *

+ * API name: {@code search_after_started_at} + */ + @Nullable + public final DateTime searchAfterStartedAt() { + return this.searchAfterStartedAt; + } + + /** + * The maximum number of recoveries to return. The value must be between 1 and + * 1000. + *

+ * API name: {@code size} + */ + @Nullable + public final Integer size() { + return this.size; + } + + /** + * Return only recoveries that started at or after this time, as an ISO-8601 + * timestamp. + *

+ * API name: {@code started_at_gte} + */ + @Nullable + public final DateTime startedAtGte() { + return this.startedAtGte; + } + + /** + * Return only recoveries that started before this time, as an ISO-8601 + * timestamp. It must not be earlier than started_at_gte. + *

+ * API name: {@code started_at_lt} + */ + @Nullable + public final DateTime startedAtLt() { + return this.startedAtLt; + } + + /** + * A comma-separated list of statuses. Return only recoveries with one of these + * statuses. By default, recoveries with any status are returned. + *

+ * API name: {@code status} + */ + public final List status() { + return this.status; + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ListRecoveriesRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private SortOrder order; + + @Nullable + private String searchAfterRecoveryId; + + @Nullable + private DateTime searchAfterStartedAt; + + @Nullable + private Integer size; + + @Nullable + private DateTime startedAtGte; + + @Nullable + private DateTime startedAtLt; + + @Nullable + private List status; + + public Builder() { + } + private Builder(ListRecoveriesRequest instance) { + this.order = instance.order; + this.searchAfterRecoveryId = instance.searchAfterRecoveryId; + this.searchAfterStartedAt = instance.searchAfterStartedAt; + this.size = instance.size; + this.startedAtGte = instance.startedAtGte; + this.startedAtLt = instance.startedAtLt; + this.status = instance.status; + + } + /** + * The order of the recoveries by start time. + *

+ * API name: {@code order} + */ + public final Builder order(@Nullable SortOrder value) { + this.order = value; + return this; + } + + /** + * Return only recoveries after this identifier in the sort order for recoveries + * with the same start time, to retrieve the next page. It must be provided + * together with search_after_started_at. + *

+ * API name: {@code search_after_recovery_id} + */ + public final Builder searchAfterRecoveryId(@Nullable String value) { + this.searchAfterRecoveryId = value; + return this; + } + + /** + * Return only recoveries after this start time in the sort order, to retrieve + * the next page. It must be provided together with + * search_after_recovery_id. + *

+ * API name: {@code search_after_started_at} + */ + public final Builder searchAfterStartedAt(@Nullable DateTime value) { + this.searchAfterStartedAt = value; + return this; + } + + /** + * The maximum number of recoveries to return. The value must be between 1 and + * 1000. + *

+ * API name: {@code size} + */ + public final Builder size(@Nullable Integer value) { + this.size = value; + return this; + } + + /** + * Return only recoveries that started at or after this time, as an ISO-8601 + * timestamp. + *

+ * API name: {@code started_at_gte} + */ + public final Builder startedAtGte(@Nullable DateTime value) { + this.startedAtGte = value; + return this; + } + + /** + * Return only recoveries that started before this time, as an ISO-8601 + * timestamp. It must not be earlier than started_at_gte. + *

+ * API name: {@code started_at_lt} + */ + public final Builder startedAtLt(@Nullable DateTime value) { + this.startedAtLt = value; + return this; + } + + /** + * A comma-separated list of statuses. Return only recoveries with one of these + * statuses. By default, recoveries with any status are returned. + *

+ * API name: {@code status} + *

+ * Adds all elements of list to status. + */ + public final Builder status(List list) { + this.status = _listAddAll(this.status, list); + return this; + } + + /** + * A comma-separated list of statuses. Return only recoveries with one of these + * statuses. By default, recoveries with any status are returned. + *

+ * API name: {@code status} + *

+ * Adds one or more values to status. + */ + public final Builder status(RecoveryRunStatus value, RecoveryRunStatus... values) { + this.status = _listAdd(this.status, value, values); + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ListRecoveriesRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ListRecoveriesRequest build() { + _checkSingleUse(); + + return new ListRecoveriesRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code data_recovery.list_recoveries}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/data_recovery.list_recoveries", + + // Request method + request -> { + return "GET"; + + }, + + // Request path + request -> { + return "/_data_recovery/recoveries"; + + }, + + // Path parameters + request -> { + return Collections.emptyMap(); + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.startedAtGte != null) { + params.put("started_at_gte", request.startedAtGte.toString()); + } + if (request.size != null) { + params.put("size", String.valueOf(request.size)); + } + if (request.searchAfterRecoveryId != null) { + params.put("search_after_recovery_id", request.searchAfterRecoveryId); + } + if (request.searchAfterStartedAt != null) { + params.put("search_after_started_at", request.searchAfterStartedAt.toString()); + } + if (request.startedAtLt != null) { + params.put("started_at_lt", request.startedAtLt.toString()); + } + if (request.order != null) { + params.put("order", request.order.jsonValue()); + } + if (ApiTypeHelper.isDefined(request.status)) { + params.put("status", request.status.stream().map(v -> v.jsonValue()).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } + return params; + + }, SimpleEndpoint.emptyMap(), false, ListRecoveriesResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ListRecoveriesResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ListRecoveriesResponse.java new file mode 100644 index 0000000000..5439c81735 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ListRecoveriesResponse.java @@ -0,0 +1,222 @@ +/* + * 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.data_recovery; + +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.JsonpUtils; +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.util.List; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery.list_recoveries.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ListRecoveriesResponse implements JsonpSerializable { + private final List recoveries; + + private final boolean hasMore; + + // --------------------------------------------------------------------------------------------- + + private ListRecoveriesResponse(Builder builder) { + + this.recoveries = ApiTypeHelper.unmodifiableRequired(builder.recoveries, this, "recoveries"); + this.hasMore = ApiTypeHelper.requireNonNull(builder.hasMore, this, "hasMore", false); + + } + + public static ListRecoveriesResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The recoveries, in the requested order. + *

+ * API name: {@code recoveries} + */ + public final List recoveries() { + return this.recoveries; + } + + /** + * Required - Whether there are more recoveries after the last one in this page. + *

+ * API name: {@code has_more} + */ + public final boolean hasMore() { + return this.hasMore; + } + + /** + * 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.recoveries)) { + generator.writeKey("recoveries"); + generator.writeStartArray(); + for (Recovery item0 : this.recoveries) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("has_more"); + generator.write(this.hasMore); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ListRecoveriesResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private List recoveries; + + private Boolean hasMore; + + /** + * Required - The recoveries, in the requested order. + *

+ * API name: {@code recoveries} + *

+ * Adds all elements of list to recoveries. + */ + public final Builder recoveries(List list) { + this.recoveries = _listAddAll(this.recoveries, list); + return this; + } + + /** + * Required - The recoveries, in the requested order. + *

+ * API name: {@code recoveries} + *

+ * Adds one or more values to recoveries. + */ + public final Builder recoveries(Recovery value, Recovery... values) { + this.recoveries = _listAdd(this.recoveries, value, values); + return this; + } + + /** + * Required - The recoveries, in the requested order. + *

+ * API name: {@code recoveries} + *

+ * Adds a value to recoveries using a builder lambda. + */ + public final Builder recoveries(Function> fn) { + return recoveries(fn.apply(new Recovery.Builder()).build()); + } + + /** + * Required - Whether there are more recoveries after the last one in this page. + *

+ * API name: {@code has_more} + */ + public final Builder hasMore(boolean value) { + this.hasMore = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ListRecoveriesResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ListRecoveriesResponse build() { + _checkSingleUse(); + + return new ListRecoveriesResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ListRecoveriesResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ListRecoveriesResponse::setupListRecoveriesResponseDeserializer); + + protected static void setupListRecoveriesResponseDeserializer( + ObjectDeserializer op) { + + op.add(Builder::recoveries, JsonpDeserializer.arrayDeserializer(Recovery._DESERIALIZER), "recoveries"); + op.add(Builder::hasMore, JsonpDeserializer.booleanDeserializer(), "has_more"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_recovery_points/RecoveryPoint.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/Point.java similarity index 83% rename from java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_recovery_points/RecoveryPoint.java rename to java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/Point.java index 046e8b2af7..43b0500ecb 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_recovery_points/RecoveryPoint.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/Point.java @@ -17,7 +17,7 @@ * under the License. */ -package co.elastic.clients.elasticsearch.data_recovery.get_recovery_points; +package co.elastic.clients.elasticsearch.data_recovery; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; @@ -50,30 +50,29 @@ // //---------------------------------------------------------------- -// typedef: data_recovery.get_recovery_points.RecoveryPoint +// typedef: data_recovery._types.Point /** * - * @see API + * @see API * specification */ @JsonpDeserializable -public class RecoveryPoint implements JsonpSerializable { +public class Point implements JsonpSerializable { private final DateTime startTime; private final DateTime endTime; // --------------------------------------------------------------------------------------------- - private RecoveryPoint(Builder builder) { + private Point(Builder builder) { this.startTime = ApiTypeHelper.requireNonNull(builder.startTime, this, "startTime"); this.endTime = ApiTypeHelper.requireNonNull(builder.endTime, this, "endTime"); } - public static RecoveryPoint of(Function> fn) { + public static Point of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -121,17 +120,17 @@ public String toString() { // --------------------------------------------------------------------------------------------- /** - * Builder for {@link RecoveryPoint}. + * Builder for {@link Point}. */ - public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { private DateTime startTime; private DateTime endTime; public Builder() { } - private Builder(RecoveryPoint instance) { + private Builder(Point instance) { this.startTime = instance.startTime; this.endTime = instance.endTime; @@ -162,15 +161,15 @@ protected Builder self() { } /** - * Builds a {@link RecoveryPoint}. + * Builds a {@link Point}. * * @throws NullPointerException * if some of the required fields are null. */ - public RecoveryPoint build() { + public Point build() { _checkSingleUse(); - return new RecoveryPoint(this); + return new Point(this); } } @@ -183,12 +182,12 @@ public Builder rebuild() { // --------------------------------------------------------------------------------------------- /** - * Json deserializer for {@link RecoveryPoint} + * Json deserializer for {@link Point} */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - RecoveryPoint::setupRecoveryPointDeserializer); + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + Point::setupPointDeserializer); - protected static void setupRecoveryPointDeserializer(ObjectDeserializer op) { + protected static void setupPointDeserializer(ObjectDeserializer op) { op.add(Builder::startTime, DateTime._DESERIALIZER, "start_time"); op.add(Builder::endTime, DateTime._DESERIALIZER, "end_time"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/Recovery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/Recovery.java new file mode 100644 index 0000000000..0c43dbb0bd --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/Recovery.java @@ -0,0 +1,576 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.elasticsearch.data_recovery.start_recovery.RecoveryMode; +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.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.DateTime; +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.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery._types.Recovery + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class Recovery implements JsonpSerializable { + private final String recoveryId; + + private final RecoveryRunStatus status; + + private final Point recoveryPoint; + + private final RecoveryMode destinationMode; + + private final List sources; + + private final Map metadata; + + private final DateTime startedAt; + + @Nullable + private final DateTime completedAt; + + private final RecoveryProgress progress; + + private final List failures; + + private final int totalFailureCount; + + // --------------------------------------------------------------------------------------------- + + protected Recovery(AbstractBuilder builder) { + + this.recoveryId = ApiTypeHelper.requireNonNull(builder.recoveryId, this, "recoveryId"); + this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); + this.recoveryPoint = ApiTypeHelper.requireNonNull(builder.recoveryPoint, this, "recoveryPoint"); + this.destinationMode = ApiTypeHelper.requireNonNull(builder.destinationMode, this, "destinationMode"); + this.sources = ApiTypeHelper.unmodifiableRequired(builder.sources, this, "sources"); + this.metadata = ApiTypeHelper.unmodifiableRequired(builder.metadata, this, "metadata"); + this.startedAt = ApiTypeHelper.requireNonNull(builder.startedAt, this, "startedAt"); + this.completedAt = builder.completedAt; + this.progress = ApiTypeHelper.requireNonNull(builder.progress, this, "progress"); + this.failures = ApiTypeHelper.unmodifiableRequired(builder.failures, this, "failures"); + this.totalFailureCount = ApiTypeHelper.requireNonNull(builder.totalFailureCount, this, "totalFailureCount", 0); + + } + + public static Recovery recoveryOf(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The identifier of the recovery. + *

+ * API name: {@code recovery_id} + */ + public final String recoveryId() { + return this.recoveryId; + } + + /** + * Required - The status of the recovery. + *

+ * API name: {@code status} + */ + public final RecoveryRunStatus status() { + return this.status; + } + + /** + * Required - The recovery point that the sources are recovered from. + *

+ * API name: {@code recovery_point} + */ + public final Point recoveryPoint() { + return this.recoveryPoint; + } + + /** + * Required - Whether the sources are recovered in place (replace) + * or under new names (rename). + *

+ * API name: {@code destination_mode} + */ + public final RecoveryMode destinationMode() { + return this.destinationMode; + } + + /** + * Required - The sources that the requested source expressions resolved to, + * with the destinations that they are recovered to. + *

+ * API name: {@code sources} + */ + public final List sources() { + return this.sources; + } + + /** + * Required - The custom metadata that was provided when the recovery was + * started. + *

+ * API name: {@code metadata} + */ + public final Map metadata() { + return this.metadata; + } + + /** + * Required - The time when the recovery started. + *

+ * API name: {@code started_at} + */ + public final DateTime startedAt() { + return this.startedAt; + } + + /** + * The time when the recovery finished. It is omitted while the recovery is + * running. + *

+ * API name: {@code completed_at} + */ + @Nullable + public final DateTime completedAt() { + return this.completedAt; + } + + /** + * Required - The progress of the recovery. + *

+ * API name: {@code progress} + */ + public final RecoveryProgress progress() { + return this.progress; + } + + /** + * Required - The sources that could not be recovered. The list is capped, so it + * can be shorter than total_failure_count. + *

+ * API name: {@code failures} + */ + public final List failures() { + return this.failures; + } + + /** + * Required - The total number of sources that could not be recovered, including + * any that are not listed in failures. + *

+ * API name: {@code total_failure_count} + */ + public final int totalFailureCount() { + return this.totalFailureCount; + } + + /** + * 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("recovery_id"); + generator.write(this.recoveryId); + + generator.writeKey("status"); + this.status.serialize(generator, mapper); + generator.writeKey("recovery_point"); + this.recoveryPoint.serialize(generator, mapper); + + generator.writeKey("destination_mode"); + this.destinationMode.serialize(generator, mapper); + if (ApiTypeHelper.isDefined(this.sources)) { + generator.writeKey("sources"); + generator.writeStartArray(); + for (ResolvedRecoverySource item0 : this.sources) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (ApiTypeHelper.isDefined(this.metadata)) { + generator.writeKey("metadata"); + generator.writeStartObject(); + for (Map.Entry item0 : this.metadata.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("started_at"); + this.startedAt.serialize(generator, mapper); + if (this.completedAt != null) { + generator.writeKey("completed_at"); + this.completedAt.serialize(generator, mapper); + } + generator.writeKey("progress"); + this.progress.serialize(generator, mapper); + + if (ApiTypeHelper.isDefined(this.failures)) { + generator.writeKey("failures"); + generator.writeStartArray(); + for (RecoveryFailure item0 : this.failures) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("total_failure_count"); + generator.write(this.totalFailureCount); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link Recovery}. + */ + + public static class Builder extends Recovery.AbstractBuilder implements ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link Recovery}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public Recovery build() { + _checkSingleUse(); + + return new Recovery(this); + } + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + private String recoveryId; + + private RecoveryRunStatus status; + + private Point recoveryPoint; + + private RecoveryMode destinationMode; + + private List sources; + + private Map metadata; + + private DateTime startedAt; + + @Nullable + private DateTime completedAt; + + private RecoveryProgress progress; + + private List failures; + + private Integer totalFailureCount; + + /** + * Required - The identifier of the recovery. + *

+ * API name: {@code recovery_id} + */ + public final BuilderT recoveryId(String value) { + this.recoveryId = value; + return self(); + } + + /** + * Required - The status of the recovery. + *

+ * API name: {@code status} + */ + public final BuilderT status(RecoveryRunStatus value) { + this.status = value; + return self(); + } + + /** + * Required - The recovery point that the sources are recovered from. + *

+ * API name: {@code recovery_point} + */ + public final BuilderT recoveryPoint(Point value) { + this.recoveryPoint = value; + return self(); + } + + /** + * Required - The recovery point that the sources are recovered from. + *

+ * API name: {@code recovery_point} + */ + public final BuilderT recoveryPoint(Function> fn) { + return this.recoveryPoint(fn.apply(new Point.Builder()).build()); + } + + /** + * Required - Whether the sources are recovered in place (replace) + * or under new names (rename). + *

+ * API name: {@code destination_mode} + */ + public final BuilderT destinationMode(RecoveryMode value) { + this.destinationMode = value; + return self(); + } + + /** + * Required - The sources that the requested source expressions resolved to, + * with the destinations that they are recovered to. + *

+ * API name: {@code sources} + *

+ * Adds all elements of list to sources. + */ + public final BuilderT sources(List list) { + this.sources = _listAddAll(this.sources, list); + return self(); + } + + /** + * Required - The sources that the requested source expressions resolved to, + * with the destinations that they are recovered to. + *

+ * API name: {@code sources} + *

+ * Adds one or more values to sources. + */ + public final BuilderT sources(ResolvedRecoverySource value, ResolvedRecoverySource... values) { + this.sources = _listAdd(this.sources, value, values); + return self(); + } + + /** + * Required - The sources that the requested source expressions resolved to, + * with the destinations that they are recovered to. + *

+ * API name: {@code sources} + *

+ * Adds a value to sources using a builder lambda. + */ + public final BuilderT sources( + Function> fn) { + return sources(fn.apply(new ResolvedRecoverySource.Builder()).build()); + } + + /** + * Required - The custom metadata that was provided when the recovery was + * started. + *

+ * API name: {@code metadata} + *

+ * Adds all entries of map to metadata. + */ + public final BuilderT metadata(Map map) { + this.metadata = _mapPutAll(this.metadata, map); + return self(); + } + + /** + * Required - The custom metadata that was provided when the recovery was + * started. + *

+ * API name: {@code metadata} + *

+ * Adds an entry to metadata. + */ + public final BuilderT metadata(String key, JsonData value) { + this.metadata = _mapPut(this.metadata, key, value); + return self(); + } + + /** + * Required - The time when the recovery started. + *

+ * API name: {@code started_at} + */ + public final BuilderT startedAt(DateTime value) { + this.startedAt = value; + return self(); + } + + /** + * The time when the recovery finished. It is omitted while the recovery is + * running. + *

+ * API name: {@code completed_at} + */ + public final BuilderT completedAt(@Nullable DateTime value) { + this.completedAt = value; + return self(); + } + + /** + * Required - The progress of the recovery. + *

+ * API name: {@code progress} + */ + public final BuilderT progress(RecoveryProgress value) { + this.progress = value; + return self(); + } + + /** + * Required - The progress of the recovery. + *

+ * API name: {@code progress} + */ + public final BuilderT progress(Function> fn) { + return this.progress(fn.apply(new RecoveryProgress.Builder()).build()); + } + + /** + * Required - The sources that could not be recovered. The list is capped, so it + * can be shorter than total_failure_count. + *

+ * API name: {@code failures} + *

+ * Adds all elements of list to failures. + */ + public final BuilderT failures(List list) { + this.failures = _listAddAll(this.failures, list); + return self(); + } + + /** + * Required - The sources that could not be recovered. The list is capped, so it + * can be shorter than total_failure_count. + *

+ * API name: {@code failures} + *

+ * Adds one or more values to failures. + */ + public final BuilderT failures(RecoveryFailure value, RecoveryFailure... values) { + this.failures = _listAdd(this.failures, value, values); + return self(); + } + + /** + * Required - The sources that could not be recovered. The list is capped, so it + * can be shorter than total_failure_count. + *

+ * API name: {@code failures} + *

+ * Adds a value to failures using a builder lambda. + */ + public final BuilderT failures(Function> fn) { + return failures(fn.apply(new RecoveryFailure.Builder()).build()); + } + + /** + * Required - The total number of sources that could not be recovered, including + * any that are not listed in failures. + *

+ * API name: {@code total_failure_count} + */ + public final BuilderT totalFailureCount(int value) { + this.totalFailureCount = value; + return self(); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link Recovery} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + Recovery::setupRecoveryDeserializer); + + protected static > void setupRecoveryDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::recoveryId, JsonpDeserializer.stringDeserializer(), "recovery_id"); + op.add(AbstractBuilder::status, RecoveryRunStatus._DESERIALIZER, "status"); + op.add(AbstractBuilder::recoveryPoint, Point._DESERIALIZER, "recovery_point"); + op.add(AbstractBuilder::destinationMode, RecoveryMode._DESERIALIZER, "destination_mode"); + op.add(AbstractBuilder::sources, JsonpDeserializer.arrayDeserializer(ResolvedRecoverySource._DESERIALIZER), + "sources"); + op.add(AbstractBuilder::metadata, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "metadata"); + op.add(AbstractBuilder::startedAt, DateTime._DESERIALIZER, "started_at"); + op.add(AbstractBuilder::completedAt, DateTime._DESERIALIZER, "completed_at"); + op.add(AbstractBuilder::progress, RecoveryProgress._DESERIALIZER, "progress"); + op.add(AbstractBuilder::failures, JsonpDeserializer.arrayDeserializer(RecoveryFailure._DESERIALIZER), + "failures"); + op.add(AbstractBuilder::totalFailureCount, JsonpDeserializer.integerDeserializer(), "total_failure_count"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/RecoveryFailure.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/RecoveryFailure.java new file mode 100644 index 0000000000..75be90a9a9 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/RecoveryFailure.java @@ -0,0 +1,236 @@ +/* + * 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.data_recovery; + +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery._types.RecoveryFailure + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class RecoveryFailure implements JsonpSerializable { + private final String source; + + private final String reason; + + @Nullable + private final String detail; + + // --------------------------------------------------------------------------------------------- + + private RecoveryFailure(Builder builder) { + + this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); + this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason"); + this.detail = builder.detail; + + } + + public static RecoveryFailure of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The name of the source that could not be recovered. + *

+ * API name: {@code source} + */ + public final String source() { + return this.source; + } + + /** + * Required - A stable, machine-readable code for the reason that the source + * could not be recovered. + *

+ * API name: {@code reason} + */ + public final String reason() { + return this.reason; + } + + /** + * Human-readable detail about the failure, which can be truncated. + *

+ * API name: {@code detail} + */ + @Nullable + public final String detail() { + return this.detail; + } + + /** + * 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("source"); + generator.write(this.source); + + generator.writeKey("reason"); + generator.write(this.reason); + + if (this.detail != null) { + generator.writeKey("detail"); + generator.write(this.detail); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RecoveryFailure}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private String source; + + private String reason; + + @Nullable + private String detail; + + public Builder() { + } + private Builder(RecoveryFailure instance) { + this.source = instance.source; + this.reason = instance.reason; + this.detail = instance.detail; + + } + /** + * Required - The name of the source that could not be recovered. + *

+ * API name: {@code source} + */ + public final Builder source(String value) { + this.source = value; + return this; + } + + /** + * Required - A stable, machine-readable code for the reason that the source + * could not be recovered. + *

+ * API name: {@code reason} + */ + public final Builder reason(String value) { + this.reason = value; + return this; + } + + /** + * Human-readable detail about the failure, which can be truncated. + *

+ * API name: {@code detail} + */ + public final Builder detail(@Nullable String value) { + this.detail = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link RecoveryFailure}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RecoveryFailure build() { + _checkSingleUse(); + + return new RecoveryFailure(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RecoveryFailure} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + RecoveryFailure::setupRecoveryFailureDeserializer); + + protected static void setupRecoveryFailureDeserializer(ObjectDeserializer op) { + + op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); + op.add(Builder::reason, JsonpDeserializer.stringDeserializer(), "reason"); + op.add(Builder::detail, JsonpDeserializer.stringDeserializer(), "detail"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/RecoveryProgress.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/RecoveryProgress.java new file mode 100644 index 0000000000..10b5dfb687 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/RecoveryProgress.java @@ -0,0 +1,181 @@ +/* + * 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.data_recovery; + +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.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Integer; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery._types.RecoveryProgress + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class RecoveryProgress implements JsonpSerializable { + @Nullable + private final Integer percentComplete; + + // --------------------------------------------------------------------------------------------- + + private RecoveryProgress(Builder builder) { + + this.percentComplete = builder.percentComplete; + + } + + public static RecoveryProgress of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The estimated percentage of the recovery that has completed, from + * 0 to 100. It is omitted when the progress cannot + * currently be determined, for example before the recovery starts moving data. + * It is 100 once the recovery has completed. + *

+ * API name: {@code percent_complete} + */ + @Nullable + public final Integer percentComplete() { + return this.percentComplete; + } + + /** + * 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 (this.percentComplete != null) { + generator.writeKey("percent_complete"); + generator.write(this.percentComplete); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RecoveryProgress}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable + private Integer percentComplete; + + public Builder() { + } + private Builder(RecoveryProgress instance) { + this.percentComplete = instance.percentComplete; + + } + /** + * The estimated percentage of the recovery that has completed, from + * 0 to 100. It is omitted when the progress cannot + * currently be determined, for example before the recovery starts moving data. + * It is 100 once the recovery has completed. + *

+ * API name: {@code percent_complete} + */ + public final Builder percentComplete(@Nullable Integer value) { + this.percentComplete = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link RecoveryProgress}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RecoveryProgress build() { + _checkSingleUse(); + + return new RecoveryProgress(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RecoveryProgress} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + RecoveryProgress::setupRecoveryProgressDeserializer); + + protected static void setupRecoveryProgressDeserializer(ObjectDeserializer op) { + + op.add(Builder::percentComplete, JsonpDeserializer.integerDeserializer(), "percent_complete"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/RecoveryRunStatus.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/RecoveryRunStatus.java new file mode 100644 index 0000000000..3e2eaf28c8 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/RecoveryRunStatus.java @@ -0,0 +1,79 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum RecoveryRunStatus implements JsonEnum { + /** + * The recovery has not finished. + */ + Running("running"), + + /** + * Every source was recovered. + */ + Completed("completed"), + + /** + * The recovery stopped without recovering every source. The + * failures of the recovery describe why. + */ + Failed("failed"), + + ; + + private final String jsonValue; + + RecoveryRunStatus(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + RecoveryRunStatus.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ResolvedRecoverySource.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ResolvedRecoverySource.java new file mode 100644 index 0000000000..412526b116 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ResolvedRecoverySource.java @@ -0,0 +1,232 @@ +/* + * 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.data_recovery; + +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery._types.ResolvedRecoverySource + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ResolvedRecoverySource implements JsonpSerializable { + private final String source; + + private final SourceType type; + + private final String destination; + + // --------------------------------------------------------------------------------------------- + + private ResolvedRecoverySource(Builder builder) { + + this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.destination = ApiTypeHelper.requireNonNull(builder.destination, this, "destination"); + + } + + public static ResolvedRecoverySource of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The name of the index or data stream in the recovery point. + *

+ * API name: {@code source} + */ + public final String source() { + return this.source; + } + + /** + * Required - The type of the source. + *

+ * API name: {@code type} + */ + public final SourceType type() { + return this.type; + } + + /** + * Required - The name of the index or data stream that the source is recovered + * to. + *

+ * API name: {@code destination} + */ + public final String destination() { + return this.destination; + } + + /** + * 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("source"); + generator.write(this.source); + + generator.writeKey("type"); + this.type.serialize(generator, mapper); + generator.writeKey("destination"); + generator.write(this.destination); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ResolvedRecoverySource}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String source; + + private SourceType type; + + private String destination; + + public Builder() { + } + private Builder(ResolvedRecoverySource instance) { + this.source = instance.source; + this.type = instance.type; + this.destination = instance.destination; + + } + /** + * Required - The name of the index or data stream in the recovery point. + *

+ * API name: {@code source} + */ + public final Builder source(String value) { + this.source = value; + return this; + } + + /** + * Required - The type of the source. + *

+ * API name: {@code type} + */ + public final Builder type(SourceType value) { + this.type = value; + return this; + } + + /** + * Required - The name of the index or data stream that the source is recovered + * to. + *

+ * API name: {@code destination} + */ + public final Builder destination(String value) { + this.destination = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ResolvedRecoverySource}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ResolvedRecoverySource build() { + _checkSingleUse(); + + return new ResolvedRecoverySource(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ResolvedRecoverySource} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ResolvedRecoverySource::setupResolvedRecoverySourceDeserializer); + + protected static void setupResolvedRecoverySourceDeserializer( + ObjectDeserializer op) { + + op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); + op.add(Builder::type, SourceType._DESERIALIZER, "type"); + op.add(Builder::destination, JsonpDeserializer.stringDeserializer(), "destination"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/SourceType.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/SourceType.java new file mode 100644 index 0000000000..d47d0e0bf0 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/SourceType.java @@ -0,0 +1,66 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum SourceType implements JsonEnum { + Index("index"), + + DataStream("data_stream"), + + ; + + private final String jsonValue; + + SourceType(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + SourceType.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/StartRecoveryRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/StartRecoveryRequest.java new file mode 100644 index 0000000000..8af2d6afba --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/StartRecoveryRequest.java @@ -0,0 +1,458 @@ +/* + * 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.data_recovery; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.RequestBase; +import co.elastic.clients.elasticsearch._types.Time; +import co.elastic.clients.elasticsearch.data_recovery.start_recovery.RecoveryMode; +import co.elastic.clients.elasticsearch.data_recovery.start_recovery.RenameStrategy; +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.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.DateTime; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.String; +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 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: data_recovery.start_recovery.Request + +/** + * Start a recovery. + *

+ * Start recovering indices and data streams from a recovery point. This API is + * intended for internal operator use. Depending on the mode, the sources are + * either replaced with their state at the recovery point, over the data that + * currently exists, or recovered under new names. The recovery runs in the + * background, so the API returns with a 202 Accepted status once + * it has started. + * + * @see API + * specification + */ +@JsonpDeserializable +public class StartRecoveryRequest extends RequestBase implements JsonpSerializable { + @Nullable + private final Time masterTimeout; + + private final Map metadata; + + private final RecoveryMode mode; + + private final DateTime recoveryPointEndTime; + + @Nullable + private final RenameStrategy renameStrategy; + + private final List sources; + + // --------------------------------------------------------------------------------------------- + + private StartRecoveryRequest(Builder builder) { + + this.masterTimeout = builder.masterTimeout; + this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); + this.mode = ApiTypeHelper.requireNonNull(builder.mode, this, "mode"); + this.recoveryPointEndTime = ApiTypeHelper.requireNonNull(builder.recoveryPointEndTime, this, + "recoveryPointEndTime"); + this.renameStrategy = builder.renameStrategy; + this.sources = ApiTypeHelper.unmodifiableRequired(builder.sources, this, "sources"); + + } + + public static StartRecoveryRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. + *

+ * API name: {@code master_timeout} + */ + @Nullable + public final Time masterTimeout() { + return this.masterTimeout; + } + + /** + * Custom metadata for the recovery. + *

+ * API name: {@code metadata} + */ + public final Map metadata() { + return this.metadata; + } + + /** + * Required - How to recover the sources: replace recovers them in + * place, over the data that currently exists, and rename recovers + * them under new names. + *

+ * API name: {@code mode} + */ + public final RecoveryMode mode() { + return this.mode; + } + + /** + * Required - The exact end time of the recovery point to recover from, as a + * date or epoch milliseconds. An end_time returned when listing + * recovery points can be passed back as it is. + *

+ * API name: {@code recovery_point_end_time} + */ + public final DateTime recoveryPointEndTime() { + return this.recoveryPointEndTime; + } + + /** + * How to derive the new name of each recovered source from its name. Required + * when mode is rename, and not allowed when + * mode is replace. + *

+ * API name: {@code rename_strategy} + */ + @Nullable + public final RenameStrategy renameStrategy() { + return this.renameStrategy; + } + + /** + * Required - The sources to recover. Each value is an index or data stream + * expression. Wildcards and exclusions prefixed with - are + * supported. The list must not be empty and must not contain blank values. + *

+ * API name: {@code sources} + */ + public final List sources() { + return this.sources; + } + + /** + * 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.metadata)) { + generator.writeKey("metadata"); + generator.writeStartObject(); + for (Map.Entry item0 : this.metadata.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("mode"); + this.mode.serialize(generator, mapper); + generator.writeKey("recovery_point_end_time"); + this.recoveryPointEndTime.serialize(generator, mapper); + if (this.renameStrategy != null) { + generator.writeKey("rename_strategy"); + this.renameStrategy.serialize(generator, mapper); + + } + if (ApiTypeHelper.isDefined(this.sources)) { + generator.writeKey("sources"); + generator.writeStartArray(); + for (String item0 : this.sources) { + generator.write(item0); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link StartRecoveryRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private Time masterTimeout; + + @Nullable + private Map metadata; + + private RecoveryMode mode; + + private DateTime recoveryPointEndTime; + + @Nullable + private RenameStrategy renameStrategy; + + private List sources; + + public Builder() { + } + private Builder(StartRecoveryRequest instance) { + this.masterTimeout = instance.masterTimeout; + this.metadata = instance.metadata; + this.mode = instance.mode; + this.recoveryPointEndTime = instance.recoveryPointEndTime; + this.renameStrategy = instance.renameStrategy; + this.sources = instance.sources; + + } + /** + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. + *

+ * API name: {@code master_timeout} + */ + public final Builder masterTimeout(@Nullable Time value) { + this.masterTimeout = value; + return this; + } + + /** + * The period to wait for the master node. If the master node is not available + * before the timeout expires, the request fails and returns an error. To + * indicate that the request should never timeout, set it to -1. + *

+ * API name: {@code master_timeout} + */ + public final Builder masterTimeout(Function> fn) { + return this.masterTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Custom metadata for the recovery. + *

+ * API name: {@code metadata} + *

+ * Adds all entries of map to metadata. + */ + public final Builder metadata(Map map) { + this.metadata = _mapPutAll(this.metadata, map); + return this; + } + + /** + * Custom metadata for the recovery. + *

+ * API name: {@code metadata} + *

+ * Adds an entry to metadata. + */ + public final Builder metadata(String key, JsonData value) { + this.metadata = _mapPut(this.metadata, key, value); + return this; + } + + /** + * Required - How to recover the sources: replace recovers them in + * place, over the data that currently exists, and rename recovers + * them under new names. + *

+ * API name: {@code mode} + */ + public final Builder mode(RecoveryMode value) { + this.mode = value; + return this; + } + + /** + * Required - The exact end time of the recovery point to recover from, as a + * date or epoch milliseconds. An end_time returned when listing + * recovery points can be passed back as it is. + *

+ * API name: {@code recovery_point_end_time} + */ + public final Builder recoveryPointEndTime(DateTime value) { + this.recoveryPointEndTime = value; + return this; + } + + /** + * How to derive the new name of each recovered source from its name. Required + * when mode is rename, and not allowed when + * mode is replace. + *

+ * API name: {@code rename_strategy} + */ + public final Builder renameStrategy(@Nullable RenameStrategy value) { + this.renameStrategy = value; + return this; + } + + /** + * How to derive the new name of each recovered source from its name. Required + * when mode is rename, and not allowed when + * mode is replace. + *

+ * API name: {@code rename_strategy} + */ + public final Builder renameStrategy(Function> fn) { + return this.renameStrategy(fn.apply(new RenameStrategy.Builder()).build()); + } + + /** + * Required - The sources to recover. Each value is an index or data stream + * expression. Wildcards and exclusions prefixed with - are + * supported. The list must not be empty and must not contain blank values. + *

+ * API name: {@code sources} + *

+ * Adds all elements of list to sources. + */ + public final Builder sources(List list) { + this.sources = _listAddAll(this.sources, list); + return this; + } + + /** + * Required - The sources to recover. Each value is an index or data stream + * expression. Wildcards and exclusions prefixed with - are + * supported. The list must not be empty and must not contain blank values. + *

+ * API name: {@code sources} + *

+ * Adds one or more values to sources. + */ + public final Builder sources(String value, String... values) { + this.sources = _listAdd(this.sources, value, values); + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link StartRecoveryRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public StartRecoveryRequest build() { + _checkSingleUse(); + + return new StartRecoveryRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link StartRecoveryRequest} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, StartRecoveryRequest::setupStartRecoveryRequestDeserializer); + + protected static void setupStartRecoveryRequestDeserializer(ObjectDeserializer op) { + + op.add(Builder::metadata, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "metadata"); + op.add(Builder::mode, RecoveryMode._DESERIALIZER, "mode"); + op.add(Builder::recoveryPointEndTime, DateTime._DESERIALIZER, "recovery_point_end_time"); + op.add(Builder::renameStrategy, RenameStrategy._DESERIALIZER, "rename_strategy"); + op.add(Builder::sources, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "sources"); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code data_recovery.start_recovery}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/data_recovery.start_recovery", + + // Request method + request -> { + return "POST"; + + }, + + // Request path + request -> { + return "/_data_recovery/recoveries"; + + }, + + // Path parameters + request -> { + return Collections.emptyMap(); + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } + return params; + + }, SimpleEndpoint.emptyMap(), true, StartRecoveryResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/StartRecoveryResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/StartRecoveryResponse.java new file mode 100644 index 0000000000..706152c34f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/StartRecoveryResponse.java @@ -0,0 +1,265 @@ +/* + * 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.data_recovery; + +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.JsonpUtils; +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.String; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery.start_recovery.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class StartRecoveryResponse implements JsonpSerializable { + private final String recoveryId; + + private final Point recoveryPoint; + + private final List resolvedSources; + + // --------------------------------------------------------------------------------------------- + + private StartRecoveryResponse(Builder builder) { + + this.recoveryId = ApiTypeHelper.requireNonNull(builder.recoveryId, this, "recoveryId"); + this.recoveryPoint = ApiTypeHelper.requireNonNull(builder.recoveryPoint, this, "recoveryPoint"); + this.resolvedSources = ApiTypeHelper.unmodifiableRequired(builder.resolvedSources, this, "resolvedSources"); + + } + + public static StartRecoveryResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The identifier of the recovery that was started. + *

+ * API name: {@code recovery_id} + */ + public final String recoveryId() { + return this.recoveryId; + } + + /** + * Required - The recovery point that the sources are recovered from. + *

+ * API name: {@code recovery_point} + */ + public final Point recoveryPoint() { + return this.recoveryPoint; + } + + /** + * Required - The sources that the requested source expressions resolved to, + * with the destinations that they are recovered to. + *

+ * API name: {@code resolved_sources} + */ + public final List resolvedSources() { + return this.resolvedSources; + } + + /** + * 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("recovery_id"); + generator.write(this.recoveryId); + + generator.writeKey("recovery_point"); + this.recoveryPoint.serialize(generator, mapper); + + if (ApiTypeHelper.isDefined(this.resolvedSources)) { + generator.writeKey("resolved_sources"); + generator.writeStartArray(); + for (ResolvedRecoverySource item0 : this.resolvedSources) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link StartRecoveryResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String recoveryId; + + private Point recoveryPoint; + + private List resolvedSources; + + /** + * Required - The identifier of the recovery that was started. + *

+ * API name: {@code recovery_id} + */ + public final Builder recoveryId(String value) { + this.recoveryId = value; + return this; + } + + /** + * Required - The recovery point that the sources are recovered from. + *

+ * API name: {@code recovery_point} + */ + public final Builder recoveryPoint(Point value) { + this.recoveryPoint = value; + return this; + } + + /** + * Required - The recovery point that the sources are recovered from. + *

+ * API name: {@code recovery_point} + */ + public final Builder recoveryPoint(Function> fn) { + return this.recoveryPoint(fn.apply(new Point.Builder()).build()); + } + + /** + * Required - The sources that the requested source expressions resolved to, + * with the destinations that they are recovered to. + *

+ * API name: {@code resolved_sources} + *

+ * Adds all elements of list to resolvedSources. + */ + public final Builder resolvedSources(List list) { + this.resolvedSources = _listAddAll(this.resolvedSources, list); + return this; + } + + /** + * Required - The sources that the requested source expressions resolved to, + * with the destinations that they are recovered to. + *

+ * API name: {@code resolved_sources} + *

+ * Adds one or more values to resolvedSources. + */ + public final Builder resolvedSources(ResolvedRecoverySource value, ResolvedRecoverySource... values) { + this.resolvedSources = _listAdd(this.resolvedSources, value, values); + return this; + } + + /** + * Required - The sources that the requested source expressions resolved to, + * with the destinations that they are recovered to. + *

+ * API name: {@code resolved_sources} + *

+ * Adds a value to resolvedSources using a builder lambda. + */ + public final Builder resolvedSources( + Function> fn) { + return resolvedSources(fn.apply(new ResolvedRecoverySource.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link StartRecoveryResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public StartRecoveryResponse build() { + _checkSingleUse(); + + return new StartRecoveryResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link StartRecoveryResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, StartRecoveryResponse::setupStartRecoveryResponseDeserializer); + + protected static void setupStartRecoveryResponseDeserializer(ObjectDeserializer op) { + + op.add(Builder::recoveryId, JsonpDeserializer.stringDeserializer(), "recovery_id"); + op.add(Builder::recoveryPoint, Point._DESERIALIZER, "recovery_point"); + op.add(Builder::resolvedSources, JsonpDeserializer.arrayDeserializer(ResolvedRecoverySource._DESERIALIZER), + "resolved_sources"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_recovery_sources/RecoverySource.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_recovery_sources/RecoverySource.java new file mode 100644 index 0000000000..11cb018d11 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_recovery_sources/RecoverySource.java @@ -0,0 +1,234 @@ +/* + * 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.data_recovery.get_recovery_sources; + +import co.elastic.clients.elasticsearch.data_recovery.SourceType; +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery.get_recovery_sources.RecoverySource + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class RecoverySource implements JsonpSerializable { + private final boolean complete; + + private final String name; + + private final SourceType type; + + // --------------------------------------------------------------------------------------------- + + private RecoverySource(Builder builder) { + + this.complete = ApiTypeHelper.requireNonNull(builder.complete, this, "complete", false); + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + + } + + public static RecoverySource of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - Whether the logical source was completely captured in the recovery + * point. For a data stream, this includes its backing and failure-store + * indices. + *

+ * API name: {@code complete} + */ + public final boolean complete() { + return this.complete; + } + + /** + * Required - The name of the index or data stream. + *

+ * API name: {@code name} + */ + public final String name() { + return this.name; + } + + /** + * Required - The type of logical source. + *

+ * API name: {@code type} + */ + public final SourceType type() { + return this.type; + } + + /** + * 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("complete"); + generator.write(this.complete); + + generator.writeKey("name"); + generator.write(this.name); + + generator.writeKey("type"); + this.type.serialize(generator, mapper); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RecoverySource}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private Boolean complete; + + private String name; + + private SourceType type; + + public Builder() { + } + private Builder(RecoverySource instance) { + this.complete = instance.complete; + this.name = instance.name; + this.type = instance.type; + + } + /** + * Required - Whether the logical source was completely captured in the recovery + * point. For a data stream, this includes its backing and failure-store + * indices. + *

+ * API name: {@code complete} + */ + public final Builder complete(boolean value) { + this.complete = value; + return this; + } + + /** + * Required - The name of the index or data stream. + *

+ * API name: {@code name} + */ + public final Builder name(String value) { + this.name = value; + return this; + } + + /** + * Required - The type of logical source. + *

+ * API name: {@code type} + */ + public final Builder type(SourceType value) { + this.type = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link RecoverySource}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RecoverySource build() { + _checkSingleUse(); + + return new RecoverySource(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RecoverySource} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + RecoverySource::setupRecoverySourceDeserializer); + + protected static void setupRecoverySourceDeserializer(ObjectDeserializer op) { + + op.add(Builder::complete, JsonpDeserializer.booleanDeserializer(), "complete"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + op.add(Builder::type, SourceType._DESERIALIZER, "type"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_rpo_series/RpoBucket.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_rpo_series/RpoBucket.java new file mode 100644 index 0000000000..1da4b592ea --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_rpo_series/RpoBucket.java @@ -0,0 +1,240 @@ +/* + * 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.data_recovery.get_rpo_series; + +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.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.DateTime; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Long; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery.get_rpo_series.RpoBucket + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class RpoBucket implements JsonpSerializable { + private final DateTime start; + + private final DateTime end; + + @Nullable + private final Long maxRecoveryPointAgeMillis; + + // --------------------------------------------------------------------------------------------- + + private RpoBucket(Builder builder) { + + this.start = ApiTypeHelper.requireNonNull(builder.start, this, "start"); + this.end = ApiTypeHelper.requireNonNull(builder.end, this, "end"); + this.maxRecoveryPointAgeMillis = builder.maxRecoveryPointAgeMillis; + + } + + public static RpoBucket of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The inclusive start of the bucket. + *

+ * API name: {@code start} + */ + public final DateTime start() { + return this.start; + } + + /** + * Required - The exclusive end of the bucket. The last bucket is clipped to the + * end of the range. + *

+ * API name: {@code end} + */ + public final DateTime end() { + return this.end; + } + + /** + * The greatest age, in milliseconds, that the newest recoverable state reached + * during the bucket. It is null if no retained recovery point + * covers the start of the bucket or the bucket starts in the future. + *

+ * API name: {@code max_recovery_point_age_millis} + */ + @Nullable + public final Long maxRecoveryPointAgeMillis() { + return this.maxRecoveryPointAgeMillis; + } + + /** + * 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("start"); + this.start.serialize(generator, mapper); + generator.writeKey("end"); + this.end.serialize(generator, mapper); + if (this.maxRecoveryPointAgeMillis != null) { + generator.writeKey("max_recovery_point_age_millis"); + generator.write(this.maxRecoveryPointAgeMillis); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RpoBucket}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private DateTime start; + + private DateTime end; + + @Nullable + private Long maxRecoveryPointAgeMillis; + + public Builder() { + } + private Builder(RpoBucket instance) { + this.start = instance.start; + this.end = instance.end; + this.maxRecoveryPointAgeMillis = instance.maxRecoveryPointAgeMillis; + + } + /** + * Required - The inclusive start of the bucket. + *

+ * API name: {@code start} + */ + public final Builder start(DateTime value) { + this.start = value; + return this; + } + + /** + * Required - The exclusive end of the bucket. The last bucket is clipped to the + * end of the range. + *

+ * API name: {@code end} + */ + public final Builder end(DateTime value) { + this.end = value; + return this; + } + + /** + * The greatest age, in milliseconds, that the newest recoverable state reached + * during the bucket. It is null if no retained recovery point + * covers the start of the bucket or the bucket starts in the future. + *

+ * API name: {@code max_recovery_point_age_millis} + */ + public final Builder maxRecoveryPointAgeMillis(@Nullable Long value) { + this.maxRecoveryPointAgeMillis = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link RpoBucket}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RpoBucket build() { + _checkSingleUse(); + + return new RpoBucket(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RpoBucket} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + RpoBucket::setupRpoBucketDeserializer); + + protected static void setupRpoBucketDeserializer(ObjectDeserializer op) { + + op.add(Builder::start, DateTime._DESERIALIZER, "start"); + op.add(Builder::end, DateTime._DESERIALIZER, "end"); + op.add(Builder::maxRecoveryPointAgeMillis, JsonpDeserializer.longDeserializer(), + "max_recovery_point_age_millis"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/start_recovery/RecoveryMode.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/start_recovery/RecoveryMode.java new file mode 100644 index 0000000000..a41c07dbe5 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/start_recovery/RecoveryMode.java @@ -0,0 +1,75 @@ +/* + * 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.data_recovery.start_recovery; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum RecoveryMode implements JsonEnum { + /** + * Replace each source with its state at the recovery point, in the place where + * it currently is. + */ + Replace("replace"), + + /** + * Recover each source under a new name, which is derived from its name by the + * rename_strategy. + */ + Rename("rename"), + + ; + + private final String jsonValue; + + RecoveryMode(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + RecoveryMode.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/start_recovery/RenameStrategy.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/start_recovery/RenameStrategy.java new file mode 100644 index 0000000000..7a278746c7 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/start_recovery/RenameStrategy.java @@ -0,0 +1,217 @@ +/* + * 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.data_recovery.start_recovery; + +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.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +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: data_recovery.start_recovery.RenameStrategy + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class RenameStrategy implements JsonpSerializable { + @Nullable + private final String prefix; + + @Nullable + private final String suffix; + + // --------------------------------------------------------------------------------------------- + + private RenameStrategy(Builder builder) { + + this.prefix = builder.prefix; + this.suffix = builder.suffix; + + } + + public static RenameStrategy of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Text to add at the start of the name of each recovered source. At least one + * of prefix and suffix must be set to a non-empty + * value, and both can be set together. + *

+ * API name: {@code prefix} + */ + @Nullable + public final String prefix() { + return this.prefix; + } + + /** + * Text to add at the end of the name of each recovered source. At least one of + * prefix and suffix must be set to a non-empty value, + * and both can be set together. + *

+ * API name: {@code suffix} + */ + @Nullable + public final String suffix() { + return this.suffix; + } + + /** + * 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 (this.prefix != null) { + generator.writeKey("prefix"); + generator.write(this.prefix); + + } + if (this.suffix != null) { + generator.writeKey("suffix"); + generator.write(this.suffix); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RenameStrategy}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable + private String prefix; + + @Nullable + private String suffix; + + public Builder() { + } + private Builder(RenameStrategy instance) { + this.prefix = instance.prefix; + this.suffix = instance.suffix; + + } + /** + * Text to add at the start of the name of each recovered source. At least one + * of prefix and suffix must be set to a non-empty + * value, and both can be set together. + *

+ * API name: {@code prefix} + */ + public final Builder prefix(@Nullable String value) { + this.prefix = value; + return this; + } + + /** + * Text to add at the end of the name of each recovered source. At least one of + * prefix and suffix must be set to a non-empty value, + * and both can be set together. + *

+ * API name: {@code suffix} + */ + public final Builder suffix(@Nullable String value) { + this.suffix = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link RenameStrategy}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RenameStrategy build() { + _checkSingleUse(); + + return new RenameStrategy(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RenameStrategy} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + RenameStrategy::setupRenameStrategyDeserializer); + + protected static void setupRenameStrategyDeserializer(ObjectDeserializer op) { + + op.add(Builder::prefix, JsonpDeserializer.stringDeserializer(), "prefix"); + op.add(Builder::suffix, JsonpDeserializer.stringDeserializer(), "suffix"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html index 3d97d135e7..1b4b5ce35d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html @@ -4,50 +4,50 @@ Elasticsearch API specification - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/DatasetFieldMapping.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/DatasetFieldMapping.java index 8e9de01da3..c96844cf81 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/DatasetFieldMapping.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/DatasetFieldMapping.java @@ -63,7 +63,7 @@ public class DatasetFieldMapping implements JsonpSerializable { private final String type; @Nullable - private final String path; + private final String renameFrom; @Nullable private final String format; @@ -73,7 +73,7 @@ public class DatasetFieldMapping implements JsonpSerializable { private DatasetFieldMapping(Builder builder) { this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - this.path = builder.path; + this.renameFrom = builder.renameFrom; this.format = builder.format; } @@ -94,12 +94,14 @@ public final String type() { /** * The underlying file column that this logical column reads from. This is a * read-path rename: the physical column becomes this single logical column. + * Responses always use rename_from. path, the former + * name for this field, is still accepted in requests and means the same thing. *

- * API name: {@code path} + * API name: {@code rename_from} */ @Nullable - public final String path() { - return this.path; + public final String renameFrom() { + return this.renameFrom; } /** @@ -127,9 +129,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("type"); generator.write(this.type); - if (this.path != null) { - generator.writeKey("path"); - generator.write(this.path); + if (this.renameFrom != null) { + generator.writeKey("rename_from"); + generator.write(this.renameFrom); } if (this.format != null) { @@ -157,7 +159,7 @@ public static class Builder extends WithJsonObjectBuilderBase private String type; @Nullable - private String path; + private String renameFrom; @Nullable private String format; @@ -166,7 +168,7 @@ public Builder() { } private Builder(DatasetFieldMapping instance) { this.type = instance.type; - this.path = instance.path; + this.renameFrom = instance.renameFrom; this.format = instance.format; } @@ -183,11 +185,13 @@ public final Builder type(String value) { /** * The underlying file column that this logical column reads from. This is a * read-path rename: the physical column becomes this single logical column. + * Responses always use rename_from. path, the former + * name for this field, is still accepted in requests and means the same thing. *

- * API name: {@code path} + * API name: {@code rename_from} */ - public final Builder path(@Nullable String value) { - this.path = value; + public final Builder renameFrom(@Nullable String value) { + this.renameFrom = value; return this; } @@ -237,7 +241,7 @@ public Builder rebuild() { protected static void setupDatasetFieldMappingDeserializer(ObjectDeserializer op) { op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - op.add(Builder::path, JsonpDeserializer.stringDeserializer(), "path"); + op.add(Builder::renameFrom, JsonpDeserializer.stringDeserializer(), "rename_from", "path"); op.add(Builder::format, JsonpDeserializer.stringDeserializer(), "format"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/DeleteViewRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/DeleteViewRequest.java index 3cdf1e6c28..a885ab13ca 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/DeleteViewRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/DeleteViewRequest.java @@ -60,7 +60,7 @@ /** * Delete an ES|QL view. *

- * Deletes a stored ES|QL view. + * Deletes a stored ES|QL view. Deleting a reserved view fails. * * @see API * specification diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ESQLView.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ESQLView.java index d90b89cd8a..bc23ceea1c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ESQLView.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ESQLView.java @@ -30,6 +30,7 @@ import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; import java.lang.String; import java.util.Objects; import java.util.function.Function; @@ -67,6 +68,9 @@ public class ESQLView implements JsonpSerializable { @Nullable private final String description; + @Nullable + private final Boolean reserved; + // --------------------------------------------------------------------------------------------- private ESQLView(Builder builder) { @@ -74,6 +78,7 @@ private ESQLView(Builder builder) { this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.query = ApiTypeHelper.requireNonNull(builder.query, this, "query"); this.description = builder.description; + this.reserved = builder.reserved; } @@ -109,6 +114,21 @@ public final String description() { return this.description; } + /** + * Whether this view is reserved. + *

+ * Elasticsearch creates reserved views. They can be queried and read like any + * other view. They cannot be created, updated, or deleted through the views + * API. The response includes this field only when the value is + * true. + *

+ * API name: {@code reserved} + */ + @Nullable + public final Boolean reserved() { + return this.reserved; + } + /** * Serialize this object to JSON. */ @@ -131,6 +151,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.description); } + if (this.reserved != null) { + generator.writeKey("reserved"); + generator.write(this.reserved); + + } } @@ -153,12 +178,16 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private String description; + @Nullable + private Boolean reserved; + public Builder() { } private Builder(ESQLView instance) { this.name = instance.name; this.query = instance.query; this.description = instance.description; + this.reserved = instance.reserved; } /** @@ -191,6 +220,21 @@ public final Builder description(@Nullable String value) { return this; } + /** + * Whether this view is reserved. + *

+ * Elasticsearch creates reserved views. They can be queried and read like any + * other view. They cannot be created, updated, or deleted through the views + * API. The response includes this field only when the value is + * true. + *

+ * API name: {@code reserved} + */ + public final Builder reserved(@Nullable Boolean value) { + this.reserved = value; + return this; + } + @Override protected Builder self() { return this; @@ -228,6 +272,7 @@ protected static void setupESQLViewDeserializer(ObjectDeserializer deleteDataset( /** * Delete an ES|QL view. *

- * Deletes a stored ES|QL view. + * Deletes a stored ES|QL view. Deleting a reserved view fails. * * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-delete-view">Documentation * on elastic.co */ @@ -169,13 +169,13 @@ public CompletableFuture deleteView(DeleteViewRequest reques /** * Delete an ES|QL view. *

- * Deletes a stored ES|QL view. + * Deletes a stored ES|QL view. Deleting a reserved view fails. * * @param fn * a function that initializes a builder to create the * {@link DeleteViewRequest} * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-delete-view">Documentation * on elastic.co */ @@ -342,10 +342,11 @@ public final CompletableFuture getQuery( /** * Get an ES|QL view. *

- * Returns a stored ES|QL view. + * Returns one or more stored views. A reserved view includes + * reserved set to true. * * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-get-view">Documentation * on elastic.co */ @@ -359,13 +360,14 @@ public CompletableFuture getView(GetViewRequest request) { /** * Get an ES|QL view. *

- * Returns a stored ES|QL view. + * Returns one or more stored views. A reserved view includes + * reserved set to true. * * @param fn * a function that initializes a builder to create the * {@link GetViewRequest} * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-get-view">Documentation * on elastic.co */ @@ -377,10 +379,11 @@ public final CompletableFuture getView( /** * Get an ES|QL view. *

- * Returns a stored ES|QL view. + * Returns one or more stored views. A reserved view includes + * reserved set to true. * * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-get-view">Documentation * on elastic.co */ @@ -496,9 +499,12 @@ public final CompletableFuture putDataset( /** * Create or update an ES|QL view. + *

+ * Stores an ES|QL query that runs whenever the view is referenced. A query that + * cannot be parsed is rejected. Replacing a reserved view fails. * * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-put-view">Documentation * on elastic.co */ @@ -511,12 +517,15 @@ public CompletableFuture putView(PutViewRequest request) { /** * Create or update an ES|QL view. + *

+ * Stores an ES|QL query that runs whenever the view is referenced. A query that + * cannot be parsed is rejected. Replacing a reserved view fails. * * @param fn * a function that initializes a builder to create the * {@link PutViewRequest} * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-put-view">Documentation * on elastic.co */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ElasticsearchEsqlClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ElasticsearchEsqlClient.java index bb086d03e9..a3a2e7c952 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ElasticsearchEsqlClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ElasticsearchEsqlClient.java @@ -157,10 +157,10 @@ public final DeleteDatasetResponse deleteDataset( /** * Delete an ES|QL view. *

- * Deletes a stored ES|QL view. + * Deletes a stored ES|QL view. Deleting a reserved view fails. * * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-delete-view">Documentation * on elastic.co */ @@ -174,13 +174,13 @@ public DeleteViewResponse deleteView(DeleteViewRequest request) throws IOExcepti /** * Delete an ES|QL view. *

- * Deletes a stored ES|QL view. + * Deletes a stored ES|QL view. Deleting a reserved view fails. * * @param fn * a function that initializes a builder to create the * {@link DeleteViewRequest} * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-delete-view">Documentation * on elastic.co */ @@ -349,10 +349,11 @@ public final GetQueryResponse getQuery(Function - * Returns a stored ES|QL view. + * Returns one or more stored views. A reserved view includes + * reserved set to true. * * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-get-view">Documentation * on elastic.co */ @@ -366,13 +367,14 @@ public GetViewResponse getView(GetViewRequest request) throws IOException, Elast /** * Get an ES|QL view. *

- * Returns a stored ES|QL view. + * Returns one or more stored views. A reserved view includes + * reserved set to true. * * @param fn * a function that initializes a builder to create the * {@link GetViewRequest} * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-get-view">Documentation * on elastic.co */ @@ -384,10 +386,11 @@ public final GetViewResponse getView(Function - * Returns a stored ES|QL view. + * Returns one or more stored views. A reserved view includes + * reserved set to true. * * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-get-view">Documentation * on elastic.co */ @@ -505,9 +508,12 @@ public final PutDatasetResponse putDataset(Function + * Stores an ES|QL query that runs whenever the view is referenced. A query that + * cannot be parsed is rejected. Replacing a reserved view fails. * * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-put-view">Documentation * on elastic.co */ @@ -520,12 +526,15 @@ public PutViewResponse putView(PutViewRequest request) throws IOException, Elast /** * Create or update an ES|QL view. + *

+ * Stores an ES|QL query that runs whenever the view is referenced. A query that + * cannot be parsed is rejected. Replacing a reserved view fails. * * @param fn * a function that initializes a builder to create the * {@link PutViewRequest} * @see Documentation + * "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-put-view">Documentation * on elastic.co */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/GetViewRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/GetViewRequest.java index ae4b95be8a..e3bc62fc00 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/GetViewRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/GetViewRequest.java @@ -27,14 +27,17 @@ 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.String; 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; //---------------------------------------------------------------- @@ -57,21 +60,21 @@ /** * Get an ES|QL view. *

- * Returns a stored ES|QL view. + * Returns one or more stored views. A reserved view includes + * reserved set to true. * * @see API * specification */ public class GetViewRequest extends RequestBase { - @Nullable - private final String name; + private final List name; // --------------------------------------------------------------------------------------------- private GetViewRequest(Builder builder) { - this.name = builder.name; + this.name = ApiTypeHelper.unmodifiable(builder.name); } @@ -84,8 +87,7 @@ public static GetViewRequest of(Function> *

* API name: {@code name} */ - @Nullable - public final String name() { + public final List name() { return this.name; } @@ -97,7 +99,7 @@ public final String name() { public static class Builder extends RequestBase.AbstractBuilder implements ObjectBuilder { @Nullable - private String name; + private List name; public Builder() { } @@ -109,9 +111,23 @@ private Builder(GetViewRequest instance) { * The comma-separated view names to retrieve. *

* API name: {@code name} + *

+ * Adds all elements of list to name. + */ + public final Builder name(List list) { + this.name = _listAddAll(this.name, list); + return this; + } + + /** + * The comma-separated view names to retrieve. + *

+ * API name: {@code name} + *

+ * Adds one or more values to name. */ - public final Builder name(@Nullable String value) { - this.name = value; + public final Builder name(String value, String... values) { + this.name = _listAdd(this.name, value, values); return this; } @@ -159,7 +175,7 @@ public Builder rebuild() { int propsSet = 0; - if (request.name() != null) + if (ApiTypeHelper.isDefined(request.name())) propsSet |= _name; if (propsSet == 0) { @@ -173,7 +189,9 @@ public Builder rebuild() { buf.append("/_query"); buf.append("/view"); buf.append("/"); - SimpleEndpoint.pathEncode(request.name, buf); + SimpleEndpoint.pathEncode( + request.name.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")), + buf); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); @@ -187,13 +205,14 @@ public Builder rebuild() { int propsSet = 0; - if (request.name() != null) + if (ApiTypeHelper.isDefined(request.name())) propsSet |= _name; if (propsSet == 0) { } if (propsSet == (_name)) { - params.put("name", request.name); + params.put("name", request.name.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); } return params; }, diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/PutViewRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/PutViewRequest.java index aa933f60b1..7252da29c4 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/PutViewRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/PutViewRequest.java @@ -32,8 +32,8 @@ 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.Collections; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -59,6 +59,9 @@ /** * Create or update an ES|QL view. + *

+ * Stores an ES|QL query that runs whenever the view is referenced. A query that + * cannot be parsed is rejected. Replacing a reserved view fails. * * @see API * specification @@ -72,6 +75,9 @@ public class PutViewRequest extends RequestBase implements JsonpSerializable { private final String query; + @Nullable + private final Boolean validate; + // --------------------------------------------------------------------------------------------- private PutViewRequest(Builder builder) { @@ -79,6 +85,7 @@ private PutViewRequest(Builder builder) { this.description = builder.description; this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.query = ApiTypeHelper.requireNonNull(builder.query, this, "query"); + this.validate = builder.validate; } @@ -106,7 +113,8 @@ public final String name() { } /** - * Required - The ES|QL query string from which to create a view. + * Required - The ES|QL query string that defines the view. A query that cannot + * be parsed is rejected. *

* API name: {@code query} */ @@ -114,6 +122,21 @@ public final String query() { return this.query; } + /** + * Whether to analyze the view query and return a warning when validation fails. + *

+ * Validation reports an unknown index or column, including an index the caller + * cannot read. The view is saved even when validation reports a problem. + * Failures unrelated to the query, such as an overloaded cluster, produce no + * warning. + *

+ * API name: {@code validate} + */ + @Nullable + public final Boolean validate() { + return this.validate; + } + /** * Serialize this object to JSON. */ @@ -149,12 +172,16 @@ public static class Builder extends RequestBase.AbstractBuilder impleme private String query; + @Nullable + private Boolean validate; + public Builder() { } private Builder(PutViewRequest instance) { this.description = instance.description; this.name = instance.name; this.query = instance.query; + this.validate = instance.validate; } /** @@ -178,7 +205,8 @@ public final Builder name(String value) { } /** - * Required - The ES|QL query string from which to create a view. + * Required - The ES|QL query string that defines the view. A query that cannot + * be parsed is rejected. *

* API name: {@code query} */ @@ -187,6 +215,21 @@ public final Builder query(String value) { return this; } + /** + * Whether to analyze the view query and return a warning when validation fails. + *

+ * Validation reports an unknown index or column, including an index the caller + * cannot read. The view is saved even when validation reports a problem. + * Failures unrelated to the query, such as an overloaded cluster, produce no + * warning. + *

+ * API name: {@code validate} + */ + public final Builder validate(@Nullable Boolean value) { + this.validate = value; + return this; + } + @Override protected Builder self() { return this; @@ -277,7 +320,11 @@ protected static void setupPutViewRequestDeserializer(ObjectDeserializer { - return Collections.emptyMap(); + Map params = new HashMap<>(); + if (request.validate != null) { + params.put("validate", String.valueOf(request.validate)); + } + return params; }, SimpleEndpoint.emptyMap(), true, PutViewResponse._DESERIALIZER); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/fleet/FleetSearchRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/fleet/FleetSearchRequest.java index 51cd9510d5..f20b8b9c00 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/fleet/FleetSearchRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/fleet/FleetSearchRequest.java @@ -192,6 +192,8 @@ public class FleetSearchRequest extends RequestBase implements JsonpSerializable private final List rescore; + private final List routeSlice; + private final List routing; private final Map runtimeMappings; @@ -279,6 +281,7 @@ private FleetSearchRequest(Builder builder) { this.query = builder.query; this.requestCache = builder.requestCache; this.rescore = ApiTypeHelper.unmodifiable(builder.rescore); + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); this.runtimeMappings = ApiTypeHelper.unmodifiable(builder.runtimeMappings); this.scriptFields = ApiTypeHelper.unmodifiable(builder.scriptFields); @@ -619,6 +622,24 @@ public final List rescore() { } /** + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. + *

+ * API name: {@code _slice} + */ + public final List routeSlice() { + return this.routeSlice; + } + + /** + * A custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. + *

* API name: {@code routing} */ public final List routing() { @@ -1160,6 +1181,9 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private List rescore; + @Nullable + private List routeSlice; + @Nullable private List routing; @@ -1254,6 +1278,7 @@ private Builder(FleetSearchRequest instance) { this.query = instance.query; this.requestCache = instance.requestCache; this.rescore = instance.rescore; + this.routeSlice = instance.routeSlice; this.routing = instance.routing; this.runtimeMappings = instance.runtimeMappings; this.scriptFields = instance.scriptFields; @@ -1825,6 +1850,44 @@ public final Builder rescore(Function> f } /** + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. + *

+ * API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. + */ + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifiers for a slice-enabled index + * (index.slice.enabled set to true): a single slice, + * a comma-separated list such as tenant-a,tenant-b, or + * _all to target all slices. When omitted, all slices are + * targeted. Indices that are not slice-enabled match no documents when a slice + * is specified. + *

+ * API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. + */ + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); + return this; + } + + /** + * A custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. + *

* API name: {@code routing} *

* Adds all elements of list to routing. @@ -1835,6 +1898,10 @@ public final Builder routing(List list) { } /** + * A custom value used to route operations to a specific shard. Not allowed when + * index.slice.enabled is true for the target index; + * use _slice instead. + *

* API name: {@code routing} *

* Adds one or more values to routing. @@ -2353,10 +2420,13 @@ protected static void setupFleetSearchRequestDeserializer(ObjectDeserializer { final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); @@ -2366,6 +2436,17 @@ protected static void setupFleetSearchRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) + .collect(Collectors.joining(",")), buf); + buf.append("/_fleet"); + buf.append("/_fleet_search"); + return buf.toString(); + } throw SimpleEndpoint.noPathTemplateFound("path"); }, @@ -2374,14 +2455,22 @@ protected static void setupFleetSearchRequestDeserializer(ObjectDeserializer { Map params = new HashMap<>(); final int _index = 1 << 0; + final int _routeSlice = 1 << 1; int propsSet = 0; propsSet |= _index; + if (ApiTypeHelper.isDefined(request.routeSlice())) + propsSet |= _routeSlice; if (propsSet == (_index)) { params.put("index", request.index); } + if (propsSet == (_index | _routeSlice)) { + params.put("index", request.index); + params.put("routeSlice", request.routeSlice.stream().map(v -> v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } return params; }, diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ilm/SearchableSnapshotAction.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ilm/SearchableSnapshotAction.java index 5b254180e2..338973b577 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ilm/SearchableSnapshotAction.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ilm/SearchableSnapshotAction.java @@ -19,6 +19,7 @@ package co.elastic.clients.elasticsearch.ilm; +import co.elastic.clients.elasticsearch._types.Time; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -31,6 +32,7 @@ import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; +import java.lang.Integer; import java.lang.String; import java.util.Objects; import java.util.function.Function; @@ -66,12 +68,20 @@ public class SearchableSnapshotAction implements JsonpSerializable { @Nullable private final Boolean forceMergeIndex; + @Nullable + private final Integer totalShardsPerNode; + + @Nullable + private final Time replicateFor; + // --------------------------------------------------------------------------------------------- private SearchableSnapshotAction(Builder builder) { this.snapshotRepository = ApiTypeHelper.requireNonNull(builder.snapshotRepository, this, "snapshotRepository"); this.forceMergeIndex = builder.forceMergeIndex; + this.totalShardsPerNode = builder.totalShardsPerNode; + this.replicateFor = builder.replicateFor; } @@ -94,6 +104,32 @@ public final Boolean forceMergeIndex() { return this.forceMergeIndex; } + /** + * The maximum number of shards, including primaries and replicas, that can be + * allocated to any single node for the mounted index. Must be at least 1. + *

+ * API name: {@code total_shards_per_node} + */ + @Nullable + public final Integer totalShardsPerNode() { + return this.totalShardsPerNode; + } + + /** + * The period for which the mounted index keeps one replica before the replica + * is removed. By default, the index is mounted without replicas. Must be + * positive. Only the first searchable_snapshot action in a policy + * may set this. It must fit before the next phase starts: for example, if this + * phase has a min_age of 5d and the next phase has 12d, it can be + * at most 7d. + *

+ * API name: {@code replicate_for} + */ + @Nullable + public final Time replicateFor() { + return this.replicateFor; + } + /** * Serialize this object to JSON. */ @@ -113,6 +149,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.forceMergeIndex); } + if (this.totalShardsPerNode != null) { + generator.writeKey("total_shards_per_node"); + generator.write(this.totalShardsPerNode); + + } + if (this.replicateFor != null) { + generator.writeKey("replicate_for"); + this.replicateFor.serialize(generator, mapper); + + } } @@ -135,11 +181,19 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Boolean forceMergeIndex; + @Nullable + private Integer totalShardsPerNode; + + @Nullable + private Time replicateFor; + public Builder() { } private Builder(SearchableSnapshotAction instance) { this.snapshotRepository = instance.snapshotRepository; this.forceMergeIndex = instance.forceMergeIndex; + this.totalShardsPerNode = instance.totalShardsPerNode; + this.replicateFor = instance.replicateFor; } /** @@ -158,6 +212,46 @@ public final Builder forceMergeIndex(@Nullable Boolean value) { return this; } + /** + * The maximum number of shards, including primaries and replicas, that can be + * allocated to any single node for the mounted index. Must be at least 1. + *

+ * API name: {@code total_shards_per_node} + */ + public final Builder totalShardsPerNode(@Nullable Integer value) { + this.totalShardsPerNode = value; + return this; + } + + /** + * The period for which the mounted index keeps one replica before the replica + * is removed. By default, the index is mounted without replicas. Must be + * positive. Only the first searchable_snapshot action in a policy + * may set this. It must fit before the next phase starts: for example, if this + * phase has a min_age of 5d and the next phase has 12d, it can be + * at most 7d. + *

+ * API name: {@code replicate_for} + */ + public final Builder replicateFor(@Nullable Time value) { + this.replicateFor = value; + return this; + } + + /** + * The period for which the mounted index keeps one replica before the replica + * is removed. By default, the index is mounted without replicas. Must be + * positive. Only the first searchable_snapshot action in a policy + * may set this. It must fit before the next phase starts: for example, if this + * phase has a min_age of 5d and the next phase has 12d, it can be + * at most 7d. + *

+ * API name: {@code replicate_for} + */ + public final Builder replicateFor(Function> fn) { + return this.replicateFor(fn.apply(new Time.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -195,6 +289,8 @@ protected static void setupSearchableSnapshotActionDeserializer( op.add(Builder::snapshotRepository, JsonpDeserializer.stringDeserializer(), "snapshot_repository"); op.add(Builder::forceMergeIndex, JsonpDeserializer.booleanDeserializer(), "force_merge_index"); + op.add(Builder::totalShardsPerNode, JsonpDeserializer.integerDeserializer(), "total_shards_per_node"); + op.add(Builder::replicateFor, Time._DESERIALIZER, "replicate_for"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/delete_alias/IndicesAliasesResponseBody.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/AliasesResponseBody.java similarity index 85% rename from java-client/src/main/java/co/elastic/clients/elasticsearch/indices/delete_alias/IndicesAliasesResponseBody.java rename to java-client/src/main/java/co/elastic/clients/elasticsearch/indices/AliasesResponseBody.java index 9f391e64bc..8677c666e7 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/delete_alias/IndicesAliasesResponseBody.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/AliasesResponseBody.java @@ -17,7 +17,7 @@ * under the License. */ -package co.elastic.clients.elasticsearch.indices.delete_alias; +package co.elastic.clients.elasticsearch.indices; import co.elastic.clients.elasticsearch._types.AcknowledgedResponseBase; import co.elastic.clients.json.JsonpDeserializable; @@ -47,22 +47,22 @@ // //---------------------------------------------------------------- -// typedef: indices.delete_alias.IndicesAliasesResponseBody +// typedef: indices._types.AliasesResponseBody /** * * @see API + * "../doc-files/api-spec.html#indices._types.AliasesResponseBody">API * specification */ -public abstract class IndicesAliasesResponseBody extends AcknowledgedResponseBase { +public abstract class AliasesResponseBody extends AcknowledgedResponseBase { @Nullable private final Boolean errors; // --------------------------------------------------------------------------------------------- - protected IndicesAliasesResponseBody(AbstractBuilder builder) { + protected AliasesResponseBody(AbstractBuilder builder) { super(builder); this.errors = builder.errors; @@ -70,6 +70,9 @@ protected IndicesAliasesResponseBody(AbstractBuilder builder) { } /** + * If true, at least one alias action failed. The request still + * returns HTTP 200. + *

* API name: {@code errors} */ @Nullable @@ -95,6 +98,9 @@ public abstract static class AbstractBuildertrue, at least one alias action failed. The request still + * returns HTTP 200. + *

* API name: {@code errors} */ public final BuilderT errors(@Nullable Boolean value) { @@ -105,7 +111,7 @@ public final BuilderT errors(@Nullable Boolean value) { } // --------------------------------------------------------------------------------------------- - protected static > void setupIndicesAliasesResponseBodyDeserializer( + protected static > void setupAliasesResponseBodyDeserializer( ObjectDeserializer op) { AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); op.add(AbstractBuilder::errors, JsonpDeserializer.booleanDeserializer(), "errors"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/DeleteAliasResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/DeleteAliasResponse.java index 94d0daf49d..cad14e8d66 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/DeleteAliasResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/DeleteAliasResponse.java @@ -19,7 +19,6 @@ package co.elastic.clients.elasticsearch.indices; -import co.elastic.clients.elasticsearch.indices.delete_alias.IndicesAliasesResponseBody; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.ObjectBuilderDeserializer; @@ -52,7 +51,7 @@ * specification */ @JsonpDeserializable -public class DeleteAliasResponse extends IndicesAliasesResponseBody { +public class DeleteAliasResponse extends AliasesResponseBody { // --------------------------------------------------------------------------------------------- private DeleteAliasResponse(Builder builder) { @@ -70,7 +69,7 @@ public static DeleteAliasResponse of(Function + public static class Builder extends AliasesResponseBody.AbstractBuilder implements ObjectBuilder { @Override @@ -100,7 +99,7 @@ public DeleteAliasResponse build() { .lazy(Builder::new, DeleteAliasResponse::setupDeleteAliasResponseDeserializer); protected static void setupDeleteAliasResponseDeserializer(ObjectDeserializer op) { - IndicesAliasesResponseBody.setupIndicesAliasesResponseBodyDeserializer(op); + AliasesResponseBody.setupAliasesResponseBodyDeserializer(op); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesAsyncClient.java index 29fd654136..04c3df4022 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesAsyncClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesAsyncClient.java @@ -2137,7 +2137,7 @@ public final CompletableFuture getDataStreamSetti // ----- Endpoint: indices.get_field_mapping /** - * Get mapping definitions. + * Get field mapping definitions. *

* Retrieves mapping definitions for one or more fields. For data streams, the * API retrieves field mappings for the stream’s backing indices. @@ -2158,7 +2158,7 @@ public CompletableFuture getFieldMapping(GetFieldMappin } /** - * Get mapping definitions. + * Get field mapping definitions. *

* Retrieves mapping definitions for one or more fields. For data streams, the * API retrieves field mappings for the stream’s backing indices. @@ -4219,9 +4219,9 @@ public final CompletableFuture resolveIndex( /** * Roll over to a new index. *

- * TIP: We recommend using the index lifecycle rollover action to automate - * rollovers. However, Serverless does not support Index Lifecycle Management - * (ILM), so don't use this approach in the Serverless context. + * TIP: To automate rollovers, use index lifecycle management (ILM) in + * deployments that support it. Serverless does not support ILM. For data + * streams in Serverless, use data stream lifecycle instead. *

* The rollover API creates a new index for a data stream or index alias. The * API behavior depends on the rollover target. @@ -4287,9 +4287,9 @@ public CompletableFuture rollover(RolloverRequest request) { /** * Roll over to a new index. *

- * TIP: We recommend using the index lifecycle rollover action to automate - * rollovers. However, Serverless does not support Index Lifecycle Management - * (ILM), so don't use this approach in the Serverless context. + * TIP: To automate rollovers, use index lifecycle management (ILM) in + * deployments that support it. Serverless does not support ILM. For data + * streams in Serverless, use data stream lifecycle instead. *

* The rollover API creates a new index for a data stream or index alias. The * API behavior depends on the rollover target. @@ -5012,9 +5012,21 @@ public CompletableFuture stats() { // ----- Endpoint: indices.update_aliases /** - * Create or update an alias. + * Update aliases and delete indices atomically. *

- * Adds a data stream or index to an alias. + * Applies one or more actions in a single request: + *

+ *

+ * For example, you can replace an index with an alias of the same name. + *

+ * NOTE: Every remove_index action in the request runs first, + * before any add or remove actions, no matter where + * it sits in the actions array. * * @see Documentation @@ -5029,9 +5041,21 @@ public CompletableFuture updateAliases(UpdateAliasesReque } /** - * Create or update an alias. + * Update aliases and delete indices atomically. *

- * Adds a data stream or index to an alias. + * Applies one or more actions in a single request: + *

+ *

+ * For example, you can replace an index with an alias of the same name. + *

+ * NOTE: Every remove_index action in the request runs first, + * before any add or remove actions, no matter where + * it sits in the actions array. * * @param fn * a function that initializes a builder to create the @@ -5047,9 +5071,21 @@ public final CompletableFuture updateAliases( } /** - * Create or update an alias. + * Update aliases and delete indices atomically. *

- * Adds a data stream or index to an alias. + * Applies one or more actions in a single request: + *

    + *
  • Add a data stream or index to an alias.
  • + *
  • Remove a data stream or index from an alias.
  • + *
  • Delete an index in that same request, so the deletion and the alias + * changes are applied together.
  • + *
+ *

+ * For example, you can replace an index with an alias of the same name. + *

+ * NOTE: Every remove_index action in the request runs first, + * before any add or remove actions, no matter where + * it sits in the actions array. * * @see Documentation diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesClient.java index c05f67c8d9..ee6255ab46 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesClient.java @@ -2166,7 +2166,7 @@ public final GetDataStreamSettingsResponse getDataStreamSettings( // ----- Endpoint: indices.get_field_mapping /** - * Get mapping definitions. + * Get field mapping definitions. *

* Retrieves mapping definitions for one or more fields. For data streams, the * API retrieves field mappings for the stream’s backing indices. @@ -2188,7 +2188,7 @@ public GetFieldMappingResponse getFieldMapping(GetFieldMappingRequest request) } /** - * Get mapping definitions. + * Get field mapping definitions. *

* Retrieves mapping definitions for one or more fields. For data streams, the * API retrieves field mappings for the stream’s backing indices. @@ -4281,9 +4281,9 @@ public final ResolveIndexResponse resolveIndex( /** * Roll over to a new index. *

- * TIP: We recommend using the index lifecycle rollover action to automate - * rollovers. However, Serverless does not support Index Lifecycle Management - * (ILM), so don't use this approach in the Serverless context. + * TIP: To automate rollovers, use index lifecycle management (ILM) in + * deployments that support it. Serverless does not support ILM. For data + * streams in Serverless, use data stream lifecycle instead. *

* The rollover API creates a new index for a data stream or index alias. The * API behavior depends on the rollover target. @@ -4349,9 +4349,9 @@ public RolloverResponse rollover(RolloverRequest request) throws IOException, El /** * Roll over to a new index. *

- * TIP: We recommend using the index lifecycle rollover action to automate - * rollovers. However, Serverless does not support Index Lifecycle Management - * (ILM), so don't use this approach in the Serverless context. + * TIP: To automate rollovers, use index lifecycle management (ILM) in + * deployments that support it. Serverless does not support ILM. For data + * streams in Serverless, use data stream lifecycle instead. *

* The rollover API creates a new index for a data stream or index alias. The * API behavior depends on the rollover target. @@ -5079,9 +5079,21 @@ public IndicesStatsResponse stats() throws IOException, ElasticsearchException { // ----- Endpoint: indices.update_aliases /** - * Create or update an alias. + * Update aliases and delete indices atomically. *

- * Adds a data stream or index to an alias. + * Applies one or more actions in a single request: + *

+ *

+ * For example, you can replace an index with an alias of the same name. + *

+ * NOTE: Every remove_index action in the request runs first, + * before any add or remove actions, no matter where + * it sits in the actions array. * * @see Documentation @@ -5097,9 +5109,21 @@ public UpdateAliasesResponse updateAliases(UpdateAliasesRequest request) } /** - * Create or update an alias. + * Update aliases and delete indices atomically. *

- * Adds a data stream or index to an alias. + * Applies one or more actions in a single request: + *

+ *

+ * For example, you can replace an index with an alias of the same name. + *

+ * NOTE: Every remove_index action in the request runs first, + * before any add or remove actions, no matter where + * it sits in the actions array. * * @param fn * a function that initializes a builder to create the @@ -5116,9 +5140,21 @@ public final UpdateAliasesResponse updateAliases( } /** - * Create or update an alias. + * Update aliases and delete indices atomically. *

- * Adds a data stream or index to an alias. + * Applies one or more actions in a single request: + *

    + *
  • Add a data stream or index to an alias.
  • + *
  • Remove a data stream or index from an alias.
  • + *
  • Delete an index in that same request, so the deletion and the alias + * changes are applied together.
  • + *
+ *

+ * For example, you can replace an index with an alias of the same name. + *

+ * NOTE: Every remove_index action in the request runs first, + * before any add or remove actions, no matter where + * it sits in the actions array. * * @see Documentation diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/GetFieldMappingRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/GetFieldMappingRequest.java index c14bcf70d3..9101c1f8d2 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/GetFieldMappingRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/GetFieldMappingRequest.java @@ -59,7 +59,7 @@ // typedef: indices.get_field_mapping.Request /** - * Get mapping definitions. + * Get field mapping definitions. *

* Retrieves mapping definitions for one or more fields. For data streams, the * API retrieves field mappings for the stream’s backing indices. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexRoutingAllocation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexRoutingAllocation.java index 907ec08af7..edf10f2441 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexRoutingAllocation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexRoutingAllocation.java @@ -26,9 +26,13 @@ import co.elastic.clients.json.JsonpUtils; 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.String; +import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -64,6 +68,8 @@ public class IndexRoutingAllocation implements JsonpSerializable { @Nullable private final IndexRoutingAllocationInclude include; + private final Map> require; + @Nullable private final IndexRoutingAllocationInitialRecovery initialRecovery; @@ -76,6 +82,7 @@ private IndexRoutingAllocation(Builder builder) { this.enable = builder.enable; this.include = builder.include; + this.require = ApiTypeHelper.unmodifiable(builder.require); this.initialRecovery = builder.initialRecovery; this.disk = builder.disk; @@ -101,6 +108,20 @@ public final IndexRoutingAllocationInclude include() { return this.include; } + /** + * Assign the index to a node whose attribute has all of the given values. Each + * key is a node attribute: one of the built-in attributes _name, + * _host_ip, _publish_ip, _ip, + * _host, _id and _tier, or a custom node + * attribute. Each value is a comma-separated string or an array of strings, and + * can use wildcards. + *

+ * API name: {@code require} + */ + public final Map> require() { + return this.require; + } + /** * API name: {@code initial_recovery} */ @@ -136,6 +157,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("include"); this.include.serialize(generator, mapper); + } + if (ApiTypeHelper.isDefined(this.require)) { + generator.writeKey("require"); + generator.writeStartObject(); + for (Map.Entry> item0 : this.require.entrySet()) { + generator.writeKey(item0.getKey()); + generator.writeStartArray(); + if (item0.getValue() != null) { + for (String item1 : item0.getValue()) { + generator.write(item1); + + } + } + generator.writeEnd(); + + } + generator.writeEnd(); + } if (this.initialRecovery != null) { generator.writeKey("initial_recovery"); @@ -170,6 +209,9 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private IndexRoutingAllocationInclude include; + @Nullable + private Map> require; + @Nullable private IndexRoutingAllocationInitialRecovery initialRecovery; @@ -181,6 +223,7 @@ public Builder() { private Builder(IndexRoutingAllocation instance) { this.enable = instance.enable; this.include = instance.include; + this.require = instance.require; this.initialRecovery = instance.initialRecovery; this.disk = instance.disk; @@ -209,6 +252,40 @@ public final Builder include( return this.include(fn.apply(new IndexRoutingAllocationInclude.Builder()).build()); } + /** + * Assign the index to a node whose attribute has all of the given values. Each + * key is a node attribute: one of the built-in attributes _name, + * _host_ip, _publish_ip, _ip, + * _host, _id and _tier, or a custom node + * attribute. Each value is a comma-separated string or an array of strings, and + * can use wildcards. + *

+ * API name: {@code require} + *

+ * Adds all entries of map to require. + */ + public final Builder require(Map> map) { + this.require = _mapPutAll(this.require, map); + return this; + } + + /** + * Assign the index to a node whose attribute has all of the given values. Each + * key is a node attribute: one of the built-in attributes _name, + * _host_ip, _publish_ip, _ip, + * _host, _id and _tier, or a custom node + * attribute. Each value is a comma-separated string or an array of strings, and + * can use wildcards. + *

+ * API name: {@code require} + *

+ * Adds an entry to require. + */ + public final Builder require(String key, List value) { + this.require = _mapPut(this.require, key, value); + return this; + } + /** * API name: {@code initial_recovery} */ @@ -278,6 +355,8 @@ protected static void setupIndexRoutingAllocationDeserializer( op.add(Builder::enable, IndexRoutingAllocationOptions._DESERIALIZER, "enable"); op.add(Builder::include, IndexRoutingAllocationInclude._DESERIALIZER, "include"); + op.add(Builder::require, JsonpDeserializer.stringMapDeserializer( + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer())), "require"); op.add(Builder::initialRecovery, IndexRoutingAllocationInitialRecovery._DESERIALIZER, "initial_recovery"); op.add(Builder::disk, IndexRoutingAllocationDisk._DESERIALIZER, "disk"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndicesStatsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndicesStatsRequest.java index e70b34d8d8..bd66dbede6 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndicesStatsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndicesStatsRequest.java @@ -97,6 +97,9 @@ public class IndicesStatsRequest extends RequestBase { private final List groups; + @Nullable + private final Boolean includeAutoCalibration; + @Nullable private final Boolean includeSegmentFileSizes; @@ -120,6 +123,7 @@ private IndicesStatsRequest(Builder builder) { this.fields = ApiTypeHelper.unmodifiable(builder.fields); this.forbidClosedIndices = builder.forbidClosedIndices; this.groups = ApiTypeHelper.unmodifiable(builder.groups); + this.includeAutoCalibration = builder.includeAutoCalibration; this.includeSegmentFileSizes = builder.includeSegmentFileSizes; this.includeUnloadedSegments = builder.includeUnloadedSegments; this.index = ApiTypeHelper.unmodifiable(builder.index); @@ -193,6 +197,18 @@ public final List groups() { return this.groups; } + /** + * If true, the response includes the auto-calibration information + * of each dense_vector field that supports auto-calibration. Only + * applies at the indices and shards levels. + *

+ * API name: {@code include_auto_calibration} + */ + @Nullable + public final Boolean includeAutoCalibration() { + return this.includeAutoCalibration; + } + /** * If true, the call reports the aggregated disk usage of each one of the Lucene * index files (only applies if segment stats are requested). @@ -272,6 +288,9 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private List groups; + @Nullable + private Boolean includeAutoCalibration; + @Nullable private Boolean includeSegmentFileSizes; @@ -296,6 +315,7 @@ private Builder(IndicesStatsRequest instance) { this.fields = instance.fields; this.forbidClosedIndices = instance.forbidClosedIndices; this.groups = instance.groups; + this.includeAutoCalibration = instance.includeAutoCalibration; this.includeSegmentFileSizes = instance.includeSegmentFileSizes; this.includeUnloadedSegments = instance.includeUnloadedSegments; this.index = instance.index; @@ -445,6 +465,18 @@ public final Builder groups(String value, String... values) { return this; } + /** + * If true, the response includes the auto-calibration information + * of each dense_vector field that supports auto-calibration. Only + * applies at the indices and shards levels. + *

+ * API name: {@code include_auto_calibration} + */ + public final Builder includeAutoCalibration(@Nullable Boolean value) { + this.includeAutoCalibration = 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). @@ -681,6 +713,9 @@ public Builder rebuild() { if (request.includeSegmentFileSizes != null) { params.put("include_segment_file_sizes", String.valueOf(request.includeSegmentFileSizes)); } + if (request.includeAutoCalibration != null) { + params.put("include_auto_calibration", String.valueOf(request.includeAutoCalibration)); + } return params; }, SimpleEndpoint.emptyMap(), false, IndicesStatsResponse._DESERIALIZER); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutAliasResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutAliasResponse.java index 40cbac33bf..f71a7f679f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutAliasResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutAliasResponse.java @@ -19,7 +19,6 @@ package co.elastic.clients.elasticsearch.indices; -import co.elastic.clients.elasticsearch._types.AcknowledgedResponseBase; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.ObjectBuilderDeserializer; @@ -52,7 +51,7 @@ * specification */ @JsonpDeserializable -public class PutAliasResponse extends AcknowledgedResponseBase { +public class PutAliasResponse extends AliasesResponseBody { // --------------------------------------------------------------------------------------------- private PutAliasResponse(Builder builder) { @@ -70,7 +69,7 @@ public static PutAliasResponse of(Function + public static class Builder extends AliasesResponseBody.AbstractBuilder implements ObjectBuilder { @Override @@ -100,7 +99,7 @@ public PutAliasResponse build() { PutAliasResponse::setupPutAliasResponseDeserializer); protected static void setupPutAliasResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); + AliasesResponseBody.setupAliasesResponseBodyDeserializer(op); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/RolloverRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/RolloverRequest.java index 14265bdf4f..ca9708eb81 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/RolloverRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/RolloverRequest.java @@ -65,9 +65,9 @@ /** * Roll over to a new index. *

- * TIP: We recommend using the index lifecycle rollover action to automate - * rollovers. However, Serverless does not support Index Lifecycle Management - * (ILM), so don't use this approach in the Serverless context. + * TIP: To automate rollovers, use index lifecycle management (ILM) in + * deployments that support it. Serverless does not support ILM. For data + * streams in Serverless, use data stream lifecycle instead. *

* The rollover API creates a new index for a data stream or index alias. The * API behavior depends on the rollover target. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/SegmentsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/SegmentsRequest.java index a280938ed4..3b3e9994fb 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/SegmentsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/SegmentsRequest.java @@ -77,8 +77,14 @@ public class SegmentsRequest extends RequestBase { @Nullable private final Boolean ignoreUnavailable; + @Nullable + private final Boolean includeAutoCalibration; + private final List index; + @Nullable + private final Boolean vectorFormats; + // --------------------------------------------------------------------------------------------- private SegmentsRequest(Builder builder) { @@ -86,7 +92,9 @@ private SegmentsRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.ignoreUnavailable = builder.ignoreUnavailable; + this.includeAutoCalibration = builder.includeAutoCalibration; this.index = ApiTypeHelper.unmodifiable(builder.index); + this.vectorFormats = builder.vectorFormats; } @@ -135,6 +143,18 @@ public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } + /** + * If true, the response includes the auto-calibration information + * of each segment, for the dense_vector fields that support + * auto-calibration. + *

+ * API name: {@code include_auto_calibration} + */ + @Nullable + public final Boolean includeAutoCalibration() { + return this.includeAutoCalibration; + } + /** * Comma-separated list of data streams, indices, and aliases used to limit the * request. Supports wildcards (*). To target all data streams and @@ -146,6 +166,17 @@ public final List index() { return this.index; } + /** + * If true, the response includes the vector formats used by the + * fields of each segment, in attributes. + *

+ * API name: {@code vector_formats} + */ + @Nullable + public final Boolean vectorFormats() { + return this.vectorFormats; + } + // --------------------------------------------------------------------------------------------- /** @@ -162,16 +193,24 @@ public static class Builder extends RequestBase.AbstractBuilder impleme @Nullable private Boolean ignoreUnavailable; + @Nullable + private Boolean includeAutoCalibration; + @Nullable private List index; + @Nullable + private Boolean vectorFormats; + public Builder() { } private Builder(SegmentsRequest instance) { this.allowNoIndices = instance.allowNoIndices; this.expandWildcards = instance.expandWildcards; this.ignoreUnavailable = instance.ignoreUnavailable; + this.includeAutoCalibration = instance.includeAutoCalibration; this.index = instance.index; + this.vectorFormats = instance.vectorFormats; } /** @@ -233,6 +272,18 @@ public final Builder ignoreUnavailable(@Nullable Boolean value) { return this; } + /** + * If true, the response includes the auto-calibration information + * of each segment, for the dense_vector fields that support + * auto-calibration. + *

+ * API name: {@code include_auto_calibration} + */ + public final Builder includeAutoCalibration(@Nullable Boolean value) { + this.includeAutoCalibration = value; + return this; + } + /** * Comma-separated list of data streams, indices, and aliases used to limit the * request. Supports wildcards (*). To target all data streams and @@ -261,6 +312,17 @@ public final Builder index(String value, String... values) { return this; } + /** + * If true, the response includes the vector formats used by the + * fields of each segment, in attributes. + *

+ * API name: {@code vector_formats} + */ + public final Builder vectorFormats(@Nullable Boolean value) { + this.vectorFormats = value; + return this; + } + @Override protected Builder self() { return this; @@ -347,6 +409,9 @@ public Builder rebuild() { // Request parameters request -> { Map params = new HashMap<>(); + if (request.vectorFormats != null) { + params.put("vector_formats", String.valueOf(request.vectorFormats)); + } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()) .filter(Objects::nonNull).collect(Collectors.joining(","))); @@ -357,6 +422,9 @@ public Builder rebuild() { if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } + if (request.includeAutoCalibration != null) { + params.put("include_auto_calibration", String.valueOf(request.includeAutoCalibration)); + } return params; }, SimpleEndpoint.emptyMap(), false, SegmentsResponse._DESERIALIZER); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/Storage.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/Storage.java index fc3e9167f8..21d859d80c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/Storage.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/Storage.java @@ -27,7 +27,6 @@ import co.elastic.clients.json.JsonpUtils; 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; @@ -61,6 +60,7 @@ */ @JsonpDeserializable public class Storage implements JsonpSerializable { + @Nullable private final String type; @Nullable @@ -73,7 +73,7 @@ public class Storage implements JsonpSerializable { private Storage(Builder builder) { - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.type = builder.type; this.allowMmap = builder.allowMmap; this.statsRefreshInterval = builder.statsRefreshInterval; @@ -84,8 +84,9 @@ public static Storage of(Function> fn) { } /** - * Required - API name: {@code type} + * API name: {@code type} */ + @Nullable public final String type() { return this.type; } @@ -126,9 +127,11 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("type"); - generator.write(this.type); + if (this.type != null) { + generator.writeKey("type"); + generator.write(this.type); + } if (this.allowMmap != null) { generator.writeKey("allow_mmap"); generator.write(this.allowMmap); @@ -154,6 +157,7 @@ public String toString() { */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable private String type; @Nullable @@ -171,17 +175,17 @@ private Builder(Storage instance) { } /** - * Required - API name: {@code type} + * API name: {@code type} */ - public final Builder type(String value) { + public final Builder type(@Nullable String value) { this.type = value; return this; } /** - * Required - API name: {@code type} + * API name: {@code type} */ - public final Builder type(StorageType value) { + public final Builder type(@Nullable StorageType value) { this.type = value == null ? null : value.jsonValue(); return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/UpdateAliasesRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/UpdateAliasesRequest.java index 78bfdeb1a3..aa870b376e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/UpdateAliasesRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/UpdateAliasesRequest.java @@ -61,9 +61,21 @@ // typedef: indices.update_aliases.Request /** - * Create or update an alias. + * Update aliases and delete indices atomically. *

- * Adds a data stream or index to an alias. + * Applies one or more actions in a single request: + *

    + *
  • Add a data stream or index to an alias.
  • + *
  • Remove a data stream or index from an alias.
  • + *
  • Delete an index in that same request, so the deletion and the alias + * changes are applied together.
  • + *
+ *

+ * For example, you can replace an index with an alias of the same name. + *

+ * NOTE: Every remove_index action in the request runs first, + * before any add or remove actions, no matter where + * it sits in the actions array. * * @see API * specification diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/UpdateAliasesResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/UpdateAliasesResponse.java index defd4316c4..64ae150be8 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/UpdateAliasesResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/UpdateAliasesResponse.java @@ -19,7 +19,7 @@ package co.elastic.clients.elasticsearch.indices; -import co.elastic.clients.elasticsearch._types.AcknowledgedResponseBase; +import co.elastic.clients.elasticsearch.indices.update_aliases.IndicesUpdateAliasesResponseBody; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.ObjectBuilderDeserializer; @@ -52,7 +52,7 @@ * specification */ @JsonpDeserializable -public class UpdateAliasesResponse extends AcknowledgedResponseBase { +public class UpdateAliasesResponse extends IndicesUpdateAliasesResponseBody { // --------------------------------------------------------------------------------------------- private UpdateAliasesResponse(Builder builder) { @@ -70,7 +70,7 @@ public static UpdateAliasesResponse of(Function + public static class Builder extends IndicesUpdateAliasesResponseBody.AbstractBuilder implements ObjectBuilder { @Override @@ -100,7 +100,7 @@ public UpdateAliasesResponse build() { .lazy(Builder::new, UpdateAliasesResponse::setupUpdateAliasesResponseDeserializer); protected static void setupUpdateAliasesResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); + IndicesUpdateAliasesResponseBody.setupIndicesUpdateAliasesResponseBodyDeserializer(op); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ValidateQueryRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ValidateQueryRequest.java index b9389993be..ed0aac7fbc 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ValidateQueryRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ValidateQueryRequest.java @@ -113,8 +113,7 @@ public class ValidateQueryRequest extends RequestBase implements JsonpSerializab @Nullable private final Boolean rewrite; - @Nullable - private final String routeSlice; + private final List routeSlice; private final List routing; @@ -136,7 +135,7 @@ private ValidateQueryRequest(Builder builder) { this.q = builder.q; this.query = builder.query; this.rewrite = builder.rewrite; - this.routeSlice = builder.routeSlice; + this.routeSlice = ApiTypeHelper.unmodifiable(builder.routeSlice); this.routing = ApiTypeHelper.unmodifiable(builder.routing); } @@ -308,14 +307,11 @@ public final Boolean rewrite() { /** * The slice identifier used to route the operation to a specific slice. Use the * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * routing value. When omitted, all slices are targeted. *

* API name: {@code _slice} */ - @Nullable - public final String routeSlice() { + public final List routeSlice() { return this.routeSlice; } @@ -401,7 +397,7 @@ public static class Builder extends RequestBase.AbstractBuilder private Boolean rewrite; @Nullable - private String routeSlice; + private List routeSlice; @Nullable private List routing; @@ -644,14 +640,28 @@ public final Builder rewrite(@Nullable Boolean value) { /** * The slice identifier used to route the operation to a specific slice. Use the * special value _all to target all slices without restricting to a - * routing value. Required when index.slice.enabled is - * true for the target index; not allowed when - * index.slice.enabled is false. + * routing value. When omitted, all slices are targeted. + *

+ * API name: {@code _slice} + *

+ * Adds all elements of list to routeSlice. + */ + public final Builder routeSlice(List list) { + this.routeSlice = _listAddAll(this.routeSlice, list); + return this; + } + + /** + * The slice identifier used to route the operation to a specific slice. Use the + * special value _all to target all slices without restricting to a + * routing value. When omitted, all slices are targeted. *

* API name: {@code _slice} + *

+ * Adds one or more values to routeSlice. */ - public final Builder routeSlice(@Nullable String value) { - this.routeSlice = value; + public final Builder routeSlice(String value, String... values) { + this.routeSlice = _listAdd(this.routeSlice, value, values); return this; } @@ -798,8 +808,9 @@ protected static void setupValidateQueryRequestDeserializer(ObjectDeserializer v).filter(Objects::nonNull) + .collect(Collectors.joining(","))); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/explain_data_lifecycle/DataStreamLifecycleExplain.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/explain_data_lifecycle/DataStreamLifecycleExplain.java index fd6884863b..2a6c99ee98 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/explain_data_lifecycle/DataStreamLifecycleExplain.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/explain_data_lifecycle/DataStreamLifecycleExplain.java @@ -89,6 +89,12 @@ public class DataStreamLifecycleExplain implements JsonpSerializable { @Nullable private final String error; + @Nullable + private final String frozenTransitionStatus; + + @Nullable + private final String unmanagedReason; + // --------------------------------------------------------------------------------------------- private DataStreamLifecycleExplain(Builder builder) { @@ -103,6 +109,8 @@ private DataStreamLifecycleExplain(Builder builder) { this.lifecycle = builder.lifecycle; this.generationTime = builder.generationTime; this.error = builder.error; + this.frozenTransitionStatus = builder.frozenTransitionStatus; + this.unmanagedReason = builder.unmanagedReason; } @@ -180,6 +188,22 @@ public final String error() { return this.error; } + /** + * API name: {@code frozen_transition_status} + */ + @Nullable + public final String frozenTransitionStatus() { + return this.frozenTransitionStatus; + } + + /** + * API name: {@code unmanaged_reason} + */ + @Nullable + public final String unmanagedReason() { + return this.unmanagedReason; + } + /** * Serialize this object to JSON. */ @@ -232,6 +256,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.error); } + if (this.frozenTransitionStatus != null) { + generator.writeKey("frozen_transition_status"); + generator.write(this.frozenTransitionStatus); + + } + if (this.unmanagedReason != null) { + generator.writeKey("unmanaged_reason"); + generator.write(this.unmanagedReason); + + } } @@ -274,6 +308,12 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private String error; + @Nullable + private String frozenTransitionStatus; + + @Nullable + private String unmanagedReason; + public Builder() { } private Builder(DataStreamLifecycleExplain instance) { @@ -286,6 +326,8 @@ private Builder(DataStreamLifecycleExplain instance) { this.lifecycle = instance.lifecycle; this.generationTime = instance.generationTime; this.error = instance.error; + this.frozenTransitionStatus = instance.frozenTransitionStatus; + this.unmanagedReason = instance.unmanagedReason; } /** @@ -389,6 +431,22 @@ public final Builder error(@Nullable String value) { return this; } + /** + * API name: {@code frozen_transition_status} + */ + public final Builder frozenTransitionStatus(@Nullable String value) { + this.frozenTransitionStatus = value; + return this; + } + + /** + * API name: {@code unmanaged_reason} + */ + public final Builder unmanagedReason(@Nullable String value) { + this.unmanagedReason = value; + return this; + } + @Override protected Builder self() { return this; @@ -433,6 +491,8 @@ protected static void setupDataStreamLifecycleExplainDeserializer( op.add(Builder::lifecycle, DataStreamLifecycleWithRollover._DESERIALIZER, "lifecycle"); op.add(Builder::generationTime, Time._DESERIALIZER, "generation_time"); op.add(Builder::error, JsonpDeserializer.stringDeserializer(), "error"); + op.add(Builder::frozenTransitionStatus, JsonpDeserializer.stringDeserializer(), "frozen_transition_status"); + op.add(Builder::unmanagedReason, JsonpDeserializer.stringDeserializer(), "unmanaged_reason"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/field_usage_stats/FieldSummary.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/field_usage_stats/FieldSummary.java index 4e265bbf8d..b61be24be4 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/field_usage_stats/FieldSummary.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/field_usage_stats/FieldSummary.java @@ -74,6 +74,8 @@ public class FieldSummary implements JsonpSerializable { private final Number knnVectors; + private final Number docValuesSkipper; + private final InvertedIndex invertedIndex; // --------------------------------------------------------------------------------------------- @@ -87,6 +89,7 @@ private FieldSummary(Builder builder) { this.norms = ApiTypeHelper.requireNonNull(builder.norms, this, "norms"); this.termVectors = ApiTypeHelper.requireNonNull(builder.termVectors, this, "termVectors"); this.knnVectors = ApiTypeHelper.requireNonNull(builder.knnVectors, this, "knnVectors"); + this.docValuesSkipper = ApiTypeHelper.requireNonNull(builder.docValuesSkipper, this, "docValuesSkipper"); this.invertedIndex = ApiTypeHelper.requireNonNull(builder.invertedIndex, this, "invertedIndex"); } @@ -144,6 +147,13 @@ public final Number knnVectors() { return this.knnVectors; } + /** + * Required - API name: {@code doc_values_skipper} + */ + public final Number docValuesSkipper() { + return this.docValuesSkipper; + } + /** * Required - API name: {@code inverted_index} */ @@ -183,6 +193,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("knn_vectors"); generator.write(this.knnVectors.doubleValue()); + generator.writeKey("doc_values_skipper"); + generator.write(this.docValuesSkipper.doubleValue()); + generator.writeKey("inverted_index"); this.invertedIndex.serialize(generator, mapper); @@ -214,6 +227,8 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Number knnVectors; + private Number docValuesSkipper; + private InvertedIndex invertedIndex; public Builder() { @@ -226,6 +241,7 @@ private Builder(FieldSummary instance) { this.norms = instance.norms; this.termVectors = instance.termVectors; this.knnVectors = instance.knnVectors; + this.docValuesSkipper = instance.docValuesSkipper; this.invertedIndex = instance.invertedIndex; } @@ -285,6 +301,14 @@ public final Builder knnVectors(Number value) { return this; } + /** + * Required - API name: {@code doc_values_skipper} + */ + public final Builder docValuesSkipper(Number value) { + this.docValuesSkipper = value; + return this; + } + /** * Required - API name: {@code inverted_index} */ @@ -341,6 +365,7 @@ protected static void setupFieldSummaryDeserializer(ObjectDeserializerAPI + * specification + */ +@JsonpDeserializable +public class OsqSegmentAutoCalibration extends SegmentAutoCalibrationBase implements SegmentAutoCalibrationVariant { + @Nullable + private final OsqSegmentAutoCalibrationParameters parameters; + + // --------------------------------------------------------------------------------------------- + + private OsqSegmentAutoCalibration(Builder builder) { + super(builder); + + this.parameters = builder.parameters; + + } + + public static OsqSegmentAutoCalibration of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * SegmentAutoCalibration variant kind. + */ + @Override + public SegmentAutoCalibration.Kind _segmentAutoCalibrationKind() { + return SegmentAutoCalibration.Kind.Osq; + } + + /** + * The calibration parameters. + *

+ * API name: {@code parameters} + */ + @Nullable + public final OsqSegmentAutoCalibrationParameters parameters() { + return this.parameters; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "osq"); + super.serializeInternal(generator, mapper); + if (this.parameters != null) { + generator.writeKey("parameters"); + this.parameters.serialize(generator, mapper); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link OsqSegmentAutoCalibration}. + */ + + public static class Builder extends SegmentAutoCalibrationBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private OsqSegmentAutoCalibrationParameters parameters; + + public Builder() { + } + private Builder(OsqSegmentAutoCalibration instance) { + this.parameters = instance.parameters; + + } + /** + * The calibration parameters. + *

+ * API name: {@code parameters} + */ + public final Builder parameters(@Nullable OsqSegmentAutoCalibrationParameters value) { + this.parameters = value; + return this; + } + + /** + * The calibration parameters. + *

+ * API name: {@code parameters} + */ + public final Builder parameters( + Function> fn) { + return this.parameters(fn.apply(new OsqSegmentAutoCalibrationParameters.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link OsqSegmentAutoCalibration}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public OsqSegmentAutoCalibration build() { + _checkSingleUse(); + + return new OsqSegmentAutoCalibration(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link OsqSegmentAutoCalibration} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, OsqSegmentAutoCalibration::setupOsqSegmentAutoCalibrationDeserializer); + + protected static void setupOsqSegmentAutoCalibrationDeserializer( + ObjectDeserializer op) { + SegmentAutoCalibrationBase.setupSegmentAutoCalibrationBaseDeserializer(op); + op.add(Builder::parameters, OsqSegmentAutoCalibrationParameters._DESERIALIZER, "parameters"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/OsqSegmentAutoCalibrationParameters.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/OsqSegmentAutoCalibrationParameters.java new file mode 100644 index 0000000000..7a3e6d3907 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/OsqSegmentAutoCalibrationParameters.java @@ -0,0 +1,265 @@ +/* + * 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.indices.segments; + +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.JsonpUtils; +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.Float; +import java.lang.Integer; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: indices.segments.OsqSegmentAutoCalibrationParameters + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class OsqSegmentAutoCalibrationParameters implements JsonpSerializable { + private final int bits; + + private final int queryBits; + + private final boolean precondition; + + private final float oversample; + + // --------------------------------------------------------------------------------------------- + + private OsqSegmentAutoCalibrationParameters(Builder builder) { + + this.bits = ApiTypeHelper.requireNonNull(builder.bits, this, "bits", 0); + this.queryBits = ApiTypeHelper.requireNonNull(builder.queryBits, this, "queryBits", 0); + this.precondition = ApiTypeHelper.requireNonNull(builder.precondition, this, "precondition", false); + this.oversample = ApiTypeHelper.requireNonNull(builder.oversample, this, "oversample", 0); + + } + + public static OsqSegmentAutoCalibrationParameters of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The number of bits used to quantize the vectors. + *

+ * API name: {@code bits} + */ + public final int bits() { + return this.bits; + } + + /** + * Required - The number of bits used to quantize the query vectors. + *

+ * API name: {@code query_bits} + */ + public final int queryBits() { + return this.queryBits; + } + + /** + * Required - If true, the vectors are preconditioned before + * quantization. + *

+ * API name: {@code precondition} + */ + public final boolean precondition() { + return this.precondition; + } + + /** + * Required - The oversampling factor applied when rescoring. + *

+ * API name: {@code oversample} + */ + public final float oversample() { + return this.oversample; + } + + /** + * 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("bits"); + generator.write(this.bits); + + generator.writeKey("query_bits"); + generator.write(this.queryBits); + + generator.writeKey("precondition"); + generator.write(this.precondition); + + generator.writeKey("oversample"); + generator.write(this.oversample); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link OsqSegmentAutoCalibrationParameters}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Integer bits; + + private Integer queryBits; + + private Boolean precondition; + + private Float oversample; + + public Builder() { + } + private Builder(OsqSegmentAutoCalibrationParameters instance) { + this.bits = instance.bits; + this.queryBits = instance.queryBits; + this.precondition = instance.precondition; + this.oversample = instance.oversample; + + } + /** + * Required - The number of bits used to quantize the vectors. + *

+ * API name: {@code bits} + */ + public final Builder bits(int value) { + this.bits = value; + return this; + } + + /** + * Required - The number of bits used to quantize the query vectors. + *

+ * API name: {@code query_bits} + */ + public final Builder queryBits(int value) { + this.queryBits = value; + return this; + } + + /** + * Required - If true, the vectors are preconditioned before + * quantization. + *

+ * API name: {@code precondition} + */ + public final Builder precondition(boolean value) { + this.precondition = value; + return this; + } + + /** + * Required - The oversampling factor applied when rescoring. + *

+ * API name: {@code oversample} + */ + public final Builder oversample(float value) { + this.oversample = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link OsqSegmentAutoCalibrationParameters}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public OsqSegmentAutoCalibrationParameters build() { + _checkSingleUse(); + + return new OsqSegmentAutoCalibrationParameters(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link OsqSegmentAutoCalibrationParameters} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + OsqSegmentAutoCalibrationParameters::setupOsqSegmentAutoCalibrationParametersDeserializer); + + protected static void setupOsqSegmentAutoCalibrationParametersDeserializer( + ObjectDeserializer op) { + + op.add(Builder::bits, JsonpDeserializer.integerDeserializer(), "bits"); + op.add(Builder::queryBits, JsonpDeserializer.integerDeserializer(), "query_bits"); + op.add(Builder::precondition, JsonpDeserializer.booleanDeserializer(), "precondition"); + op.add(Builder::oversample, JsonpDeserializer.floatDeserializer(), "oversample"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/Segment.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/Segment.java index 1faeb5a957..223abd801e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/Segment.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/Segment.java @@ -35,6 +35,7 @@ import java.lang.Integer; 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; @@ -68,7 +69,8 @@ public class Segment implements JsonpSerializable { private final boolean committed; - private final boolean compound; + @Nullable + private final Boolean compound; private final long deletedDocs; @@ -76,25 +78,40 @@ public class Segment implements JsonpSerializable { private final boolean search; + @Nullable + private final String mergeId; + + private final List sort; + + @Nullable + private final String size; + private final double sizeInBytes; private final long numDocs; + @Nullable private final String version; + private final Map autoCalibration; + // --------------------------------------------------------------------------------------------- private Segment(Builder builder) { - this.attributes = ApiTypeHelper.unmodifiableRequired(builder.attributes, this, "attributes"); + this.attributes = ApiTypeHelper.unmodifiable(builder.attributes); this.committed = ApiTypeHelper.requireNonNull(builder.committed, this, "committed", false); - this.compound = ApiTypeHelper.requireNonNull(builder.compound, this, "compound", false); + this.compound = builder.compound; this.deletedDocs = ApiTypeHelper.requireNonNull(builder.deletedDocs, this, "deletedDocs", 0); this.generation = ApiTypeHelper.requireNonNull(builder.generation, this, "generation", 0); this.search = ApiTypeHelper.requireNonNull(builder.search, this, "search", false); + this.mergeId = builder.mergeId; + this.sort = ApiTypeHelper.unmodifiable(builder.sort); + this.size = builder.size; this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes", 0); this.numDocs = ApiTypeHelper.requireNonNull(builder.numDocs, this, "numDocs", 0); - this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version"); + this.version = builder.version; + this.autoCalibration = ApiTypeHelper.unmodifiable(builder.autoCalibration); } @@ -103,8 +120,8 @@ public static Segment of(Function> fn) { } /** - * Required - Contains information about whether high compression was enabled - * and per-field vector formats. + * Contains information about whether high compression was enabled and per-field + * vector formats. *

* API name: {@code attributes} */ @@ -125,12 +142,13 @@ public final boolean committed() { } /** - * Required - If true, Lucene merged all files from the segment - * into a single file to save file descriptors. + * If true, Lucene merged all files from the segment into a single + * file to save file descriptors. *

* API name: {@code compound} */ - public final boolean compound() { + @Nullable + public final Boolean compound() { return this.compound; } @@ -170,6 +188,36 @@ public final boolean search() { return this.search; } + /** + * The ID of the merge the segment is part of. Only returned while the segment + * is being merged. + *

+ * API name: {@code merge_id} + */ + @Nullable + public final String mergeId() { + return this.mergeId; + } + + /** + * The index sort of the segment. Only returned when the index is sorted. + *

+ * API name: {@code sort} + */ + public final List sort() { + return this.sort; + } + + /** + * Disk space used by the segment. + *

+ * API name: {@code size} + */ + @Nullable + public final String size() { + return this.size; + } + /** * Required - Disk space used by the segment, in bytes. *

@@ -192,14 +240,26 @@ public final long numDocs() { } /** - * Required - Version of Lucene used to write the segment. + * Version of Lucene used to write the segment. *

* API name: {@code version} */ + @Nullable public final String version() { return this.version; } + /** + * The auto-calibration information of the segment, per + * dense_vector field that supports auto-calibration. Only returned + * when include_auto_calibration is true. + *

+ * API name: {@code auto_calibration} + */ + public final Map autoCalibration() { + return this.autoCalibration; + } + /** * Serialize this object to JSON. */ @@ -225,9 +285,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("committed"); generator.write(this.committed); - generator.writeKey("compound"); - generator.write(this.compound); + if (this.compound != null) { + generator.writeKey("compound"); + generator.write(this.compound); + } generator.writeKey("deleted_docs"); generator.write(this.deletedDocs); @@ -237,14 +299,48 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("search"); generator.write(this.search); + if (this.mergeId != null) { + generator.writeKey("merge_id"); + generator.write(this.mergeId); + + } + if (ApiTypeHelper.isDefined(this.sort)) { + generator.writeKey("sort"); + generator.writeStartArray(); + for (SegmentSort item0 : this.sort) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (this.size != null) { + generator.writeKey("size"); + generator.write(this.size); + + } generator.writeKey("size_in_bytes"); generator.write(this.sizeInBytes); generator.writeKey("num_docs"); generator.write(this.numDocs); - generator.writeKey("version"); - generator.write(this.version); + if (this.version != null) { + generator.writeKey("version"); + generator.write(this.version); + + } + if (ApiTypeHelper.isDefined(this.autoCalibration)) { + generator.writeKey("auto_calibration"); + generator.writeStartObject(); + for (Map.Entry item0 : this.autoCalibration.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } } @@ -260,10 +356,12 @@ public String toString() { */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable private Map attributes; private Boolean committed; + @Nullable private Boolean compound; private Long deletedDocs; @@ -272,12 +370,25 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Boolean search; + @Nullable + private String mergeId; + + @Nullable + private List sort; + + @Nullable + private String size; + private Double sizeInBytes; private Long numDocs; + @Nullable private String version; + @Nullable + private Map autoCalibration; + public Builder() { } private Builder(Segment instance) { @@ -287,14 +398,18 @@ private Builder(Segment instance) { this.deletedDocs = instance.deletedDocs; this.generation = instance.generation; this.search = instance.search; + this.mergeId = instance.mergeId; + this.sort = instance.sort; + this.size = instance.size; this.sizeInBytes = instance.sizeInBytes; this.numDocs = instance.numDocs; this.version = instance.version; + this.autoCalibration = instance.autoCalibration; } /** - * Required - Contains information about whether high compression was enabled - * and per-field vector formats. + * Contains information about whether high compression was enabled and per-field + * vector formats. *

* API name: {@code attributes} *

@@ -306,8 +421,8 @@ public final Builder attributes(Map map) { } /** - * Required - Contains information about whether high compression was enabled - * and per-field vector formats. + * Contains information about whether high compression was enabled and per-field + * vector formats. *

* API name: {@code attributes} *

@@ -332,12 +447,12 @@ public final Builder committed(boolean value) { } /** - * Required - If true, Lucene merged all files from the segment - * into a single file to save file descriptors. + * If true, Lucene merged all files from the segment into a single + * file to save file descriptors. *

* API name: {@code compound} */ - public final Builder compound(boolean value) { + public final Builder compound(@Nullable Boolean value) { this.compound = value; return this; } @@ -381,6 +496,62 @@ public final Builder search(boolean value) { return this; } + /** + * The ID of the merge the segment is part of. Only returned while the segment + * is being merged. + *

+ * API name: {@code merge_id} + */ + public final Builder mergeId(@Nullable String value) { + this.mergeId = value; + return this; + } + + /** + * The index sort of the segment. Only returned when the index is sorted. + *

+ * API name: {@code sort} + *

+ * Adds all elements of list to sort. + */ + public final Builder sort(List list) { + this.sort = _listAddAll(this.sort, list); + return this; + } + + /** + * The index sort of the segment. Only returned when the index is sorted. + *

+ * API name: {@code sort} + *

+ * Adds one or more values to sort. + */ + public final Builder sort(SegmentSort value, SegmentSort... values) { + this.sort = _listAdd(this.sort, value, values); + return this; + } + + /** + * The index sort of the segment. Only returned when the index is sorted. + *

+ * API name: {@code sort} + *

+ * Adds a value to sort using a builder lambda. + */ + public final Builder sort(Function> fn) { + return sort(fn.apply(new SegmentSort.Builder()).build()); + } + + /** + * Disk space used by the segment. + *

+ * API name: {@code size} + */ + public final Builder size(@Nullable String value) { + this.size = value; + return this; + } + /** * Required - Disk space used by the segment, in bytes. *

@@ -405,15 +576,57 @@ public final Builder numDocs(long value) { } /** - * Required - Version of Lucene used to write the segment. + * Version of Lucene used to write the segment. *

* API name: {@code version} */ - public final Builder version(String value) { + public final Builder version(@Nullable String value) { this.version = value; return this; } + /** + * The auto-calibration information of the segment, per + * dense_vector field that supports auto-calibration. Only returned + * when include_auto_calibration is true. + *

+ * API name: {@code auto_calibration} + *

+ * Adds all entries of map to autoCalibration. + */ + public final Builder autoCalibration(Map map) { + this.autoCalibration = _mapPutAll(this.autoCalibration, map); + return this; + } + + /** + * The auto-calibration information of the segment, per + * dense_vector field that supports auto-calibration. Only returned + * when include_auto_calibration is true. + *

+ * API name: {@code auto_calibration} + *

+ * Adds an entry to autoCalibration. + */ + public final Builder autoCalibration(String key, SegmentAutoCalibration value) { + this.autoCalibration = _mapPut(this.autoCalibration, key, value); + return this; + } + + /** + * The auto-calibration information of the segment, per + * dense_vector field that supports auto-calibration. Only returned + * when include_auto_calibration is true. + *

+ * API name: {@code auto_calibration} + *

+ * Adds an entry to autoCalibration using a builder lambda. + */ + public final Builder autoCalibration(String key, + Function> fn) { + return autoCalibration(key, fn.apply(new SegmentAutoCalibration.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -455,9 +668,14 @@ protected static void setupSegmentDeserializer(ObjectDeserializerdense_vector field in a + * segment. + *

+ * The shape of parameters depends on the quantization method of + * the field. + * + * @see API + * specification + */ +@JsonpDeserializable +public class SegmentAutoCalibration implements OpenTaggedUnion, JsonpSerializable { + + /** + * {@link SegmentAutoCalibration} variant kinds. + * + * @see API + * specification + */ + + public enum Kind implements JsonEnum { + Osq("osq"), + + /** A custom {@code SegmentAutoCalibration} defined by a plugin */ + _Custom(null) + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + public SegmentAutoCalibration(SegmentAutoCalibrationVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._segmentAutoCalibrationKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + this._customKind = null; + + } + + private SegmentAutoCalibration(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + this._customKind = builder._customKind; + + } + + public static SegmentAutoCalibration of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Build a custom plugin-defined {@code SegmentAutoCalibration}, given its kind + * and some JSON data + */ + public SegmentAutoCalibration(String kind, JsonData value) { + this._kind = Kind._Custom; + this._value = value; + this._customKind = kind; + } + + /** + * Is this variant instance of kind {@code osq}? + */ + public boolean isOsq() { + return _kind == Kind.Osq; + } + + /** + * Get the {@code osq} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code osq} kind. + */ + public OsqSegmentAutoCalibration osq() { + return TaggedUnionUtils.get(this, Kind.Osq); + } + + @Nullable + private final String _customKind; + + /** + * Is this a custom {@code SegmentAutoCalibration} defined by a plugin? + */ + public boolean _isCustom() { + return _kind == Kind._Custom; + } + + /** + * Get the actual kind when {@code _kind()} equals {@link Kind#_Custom} + * (plugin-defined variant). + */ + @Nullable + public final String _customKind() { + return _customKind; + } + + /** + * Get the custom plugin-defined variant value. + * + * @throws IllegalStateException + * if the current variant is not {@link Kind#_Custom}. + */ + public JsonData _custom() { + return TaggedUnionUtils.get(this, Kind._Custom); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + + mapper.serialize(_value, generator); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Kind _kind; + private Object _value; + private String _customKind; + + @Override + protected Builder self() { + return this; + } + public ObjectBuilder osq(OsqSegmentAutoCalibration v) { + this._kind = Kind.Osq; + this._value = v; + return this; + } + + public ObjectBuilder osq( + Function> fn) { + return this.osq(fn.apply(new OsqSegmentAutoCalibration.Builder()).build()); + } + + /** + * Define this {@code SegmentAutoCalibration} as a plugin-defined variant. + * + * @param name + * the plugin-defined identifier + * @param data + * the data for this custom {@code SegmentAutoCalibration}. It is + * converted internally to {@link JsonData}. + */ + public ObjectBuilder _custom(String name, Object data) { + this._kind = Kind._Custom; + this._customKind = name; + this._value = JsonData.of(data); + return this; + } + + public SegmentAutoCalibration build() { + _checkSingleUse(); + return new SegmentAutoCalibration(this); + } + + } + + protected static void setupSegmentAutoCalibrationDeserializer(ObjectDeserializer op) { + + op.add(Builder::osq, OsqSegmentAutoCalibration._DESERIALIZER, "osq"); + + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + JsonpUtils.ensureCustomVariantsAllowed(parser, mapper); + builder._custom(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); + + op.setTypeProperty("type", null); + + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, SegmentAutoCalibration::setupSegmentAutoCalibrationDeserializer, Builder::build); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentAutoCalibrationBase.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentAutoCalibrationBase.java new file mode 100644 index 0000000000..8fa3b330fd --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentAutoCalibrationBase.java @@ -0,0 +1,218 @@ +/* + * 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.indices.segments; + +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.JsonpUtils; +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.Long; +import java.lang.String; +import java.util.Objects; +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: indices.segments.SegmentAutoCalibrationBase + +/** + * + * @see API + * specification + */ + +public abstract class SegmentAutoCalibrationBase implements JsonpSerializable { + private final boolean calibrated; + + private final long numberOfVectors; + + @Nullable + private final String size; + + private final long sizeInBytes; + + // --------------------------------------------------------------------------------------------- + + protected SegmentAutoCalibrationBase(AbstractBuilder builder) { + + this.calibrated = ApiTypeHelper.requireNonNull(builder.calibrated, this, "calibrated", false); + this.numberOfVectors = ApiTypeHelper.requireNonNull(builder.numberOfVectors, this, "numberOfVectors", 0); + this.size = builder.size; + this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes", 0); + + } + + /** + * Required - If true, the segment has been calibrated, and + * parameters is present. + *

+ * API name: {@code calibrated} + */ + public final boolean calibrated() { + return this.calibrated; + } + + /** + * Required - The number of vectors of the field in the segment. + *

+ * API name: {@code number_of_vectors} + */ + public final long numberOfVectors() { + return this.numberOfVectors; + } + + /** + * API name: {@code size} + */ + @Nullable + public final String size() { + return this.size; + } + + /** + * Required - The size of the vectors of the field in the segment, in bytes. + *

+ * API name: {@code size_in_bytes} + */ + public final long sizeInBytes() { + return this.sizeInBytes; + } + + /** + * 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("calibrated"); + generator.write(this.calibrated); + + generator.writeKey("number_of_vectors"); + generator.write(this.numberOfVectors); + + if (this.size != null) { + generator.writeKey("size"); + generator.write(this.size); + + } + generator.writeKey("size_in_bytes"); + generator.write(this.sizeInBytes); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + private Boolean calibrated; + + private Long numberOfVectors; + + @Nullable + private String size; + + private Long sizeInBytes; + + /** + * Required - If true, the segment has been calibrated, and + * parameters is present. + *

+ * API name: {@code calibrated} + */ + public final BuilderT calibrated(boolean value) { + this.calibrated = value; + return self(); + } + + /** + * Required - The number of vectors of the field in the segment. + *

+ * API name: {@code number_of_vectors} + */ + public final BuilderT numberOfVectors(long value) { + this.numberOfVectors = value; + return self(); + } + + /** + * API name: {@code size} + */ + public final BuilderT size(@Nullable String value) { + this.size = value; + return self(); + } + + /** + * Required - The size of the vectors of the field in the segment, in bytes. + *

+ * API name: {@code size_in_bytes} + */ + public final BuilderT sizeInBytes(long value) { + this.sizeInBytes = value; + return self(); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupSegmentAutoCalibrationBaseDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::calibrated, JsonpDeserializer.booleanDeserializer(), "calibrated"); + op.add(AbstractBuilder::numberOfVectors, JsonpDeserializer.longDeserializer(), "number_of_vectors"); + op.add(AbstractBuilder::size, JsonpDeserializer.stringDeserializer(), "size"); + op.add(AbstractBuilder::sizeInBytes, JsonpDeserializer.longDeserializer(), "size_in_bytes"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentAutoCalibrationBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentAutoCalibrationBuilders.java new file mode 100644 index 0000000000..35e3f150d1 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentAutoCalibrationBuilders.java @@ -0,0 +1,66 @@ +/* + * 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.indices.segments; + +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link SegmentAutoCalibration} variants. + */ +public class SegmentAutoCalibrationBuilders { + private SegmentAutoCalibrationBuilders() { + } + + /** + * Creates a builder for the {@link OsqSegmentAutoCalibration osq} + * {@code SegmentAutoCalibration} variant. + */ + public static OsqSegmentAutoCalibration.Builder osq() { + return new OsqSegmentAutoCalibration.Builder(); + } + + /** + * Creates a SegmentAutoCalibration of the {@link OsqSegmentAutoCalibration osq} + * {@code SegmentAutoCalibration} variant. + */ + public static SegmentAutoCalibration osq( + Function> fn) { + SegmentAutoCalibration.Builder builder = new SegmentAutoCalibration.Builder(); + builder.osq(fn.apply(new OsqSegmentAutoCalibration.Builder()).build()); + return builder.build(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentAutoCalibrationVariant.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentAutoCalibrationVariant.java new file mode 100644 index 0000000000..b95ab01b07 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentAutoCalibrationVariant.java @@ -0,0 +1,50 @@ +/* + * 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.indices.segments; + +import co.elastic.clients.json.JsonpSerializable; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Base interface for {@link SegmentAutoCalibration} variants. + */ +public interface SegmentAutoCalibrationVariant extends JsonpSerializable { + + SegmentAutoCalibration.Kind _segmentAutoCalibrationKind(); + + default SegmentAutoCalibration _toSegmentAutoCalibration() { + return new SegmentAutoCalibration(this); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentSort.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentSort.java new file mode 100644 index 0000000000..6f44ca6a7f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/SegmentSort.java @@ -0,0 +1,271 @@ +/* + * 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.indices.segments; + +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: indices.segments.SegmentSort + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class SegmentSort implements JsonpSerializable { + private final String field; + + @Nullable + private final String mode; + + @Nullable + private final String missing; + + private final boolean reverse; + + // --------------------------------------------------------------------------------------------- + + private SegmentSort(Builder builder) { + + this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); + this.mode = builder.mode; + this.missing = builder.missing; + this.reverse = ApiTypeHelper.requireNonNull(builder.reverse, this, "reverse", false); + + } + + public static SegmentSort of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The name of the sort field. + *

+ * API name: {@code field} + */ + public final String field() { + return this.field; + } + + /** + * The selector used to pick a value from multi-valued fields, such as + * min or max. Only returned for numeric and keyword + * fields. + *

+ * API name: {@code mode} + */ + @Nullable + public final String mode() { + return this.mode; + } + + /** + * The value used for documents that are missing the field. + *

+ * API name: {@code missing} + */ + @Nullable + public final String missing() { + return this.missing; + } + + /** + * Required - If true, the sort order is descending. + *

+ * API name: {@code reverse} + */ + public final boolean reverse() { + return this.reverse; + } + + /** + * 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("field"); + generator.write(this.field); + + if (this.mode != null) { + generator.writeKey("mode"); + generator.write(this.mode); + + } + if (this.missing != null) { + generator.writeKey("missing"); + generator.write(this.missing); + + } + generator.writeKey("reverse"); + generator.write(this.reverse); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link SegmentSort}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private String field; + + @Nullable + private String mode; + + @Nullable + private String missing; + + private Boolean reverse; + + public Builder() { + } + private Builder(SegmentSort instance) { + this.field = instance.field; + this.mode = instance.mode; + this.missing = instance.missing; + this.reverse = instance.reverse; + + } + /** + * Required - The name of the sort field. + *

+ * API name: {@code field} + */ + public final Builder field(String value) { + this.field = value; + return this; + } + + /** + * The selector used to pick a value from multi-valued fields, such as + * min or max. Only returned for numeric and keyword + * fields. + *

+ * API name: {@code mode} + */ + public final Builder mode(@Nullable String value) { + this.mode = value; + return this; + } + + /** + * The value used for documents that are missing the field. + *

+ * API name: {@code missing} + */ + public final Builder missing(@Nullable String value) { + this.missing = value; + return this; + } + + /** + * Required - If true, the sort order is descending. + *

+ * API name: {@code reverse} + */ + public final Builder reverse(boolean value) { + this.reverse = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link SegmentSort}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public SegmentSort build() { + _checkSingleUse(); + + return new SegmentSort(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SegmentSort} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + SegmentSort::setupSegmentSortDeserializer); + + protected static void setupSegmentSortDeserializer(ObjectDeserializer op) { + + op.add(Builder::field, JsonpDeserializer.stringDeserializer(), "field"); + op.add(Builder::mode, JsonpDeserializer.stringDeserializer(), "mode"); + op.add(Builder::missing, JsonpDeserializer.stringDeserializer(), "missing"); + op.add(Builder::reverse, JsonpDeserializer.booleanDeserializer(), "reverse"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/ShardSegmentRouting.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/ShardSegmentRouting.java index f7d5f35964..a246b23786 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/ShardSegmentRouting.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/segments/ShardSegmentRouting.java @@ -63,6 +63,9 @@ public class ShardSegmentRouting implements JsonpSerializable { private final String node; + @Nullable + private final String relocatingNode; + private final boolean primary; private final String state; @@ -72,6 +75,7 @@ public class ShardSegmentRouting implements JsonpSerializable { private ShardSegmentRouting(Builder builder) { this.node = ApiTypeHelper.requireNonNull(builder.node, this, "node"); + this.relocatingNode = builder.relocatingNode; this.primary = ApiTypeHelper.requireNonNull(builder.primary, this, "primary", false); this.state = ApiTypeHelper.requireNonNull(builder.state, this, "state"); @@ -90,6 +94,17 @@ public final String node() { return this.node; } + /** + * The node ID of the node the shard is relocating to. Only returned while the + * shard is relocating. + *

+ * API name: {@code relocating_node} + */ + @Nullable + public final String relocatingNode() { + return this.relocatingNode; + } + /** * Required - If true, the shard is a primary shard. *

@@ -123,6 +138,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("node"); generator.write(this.node); + if (this.relocatingNode != null) { + generator.writeKey("relocating_node"); + generator.write(this.relocatingNode); + + } generator.writeKey("primary"); generator.write(this.primary); @@ -147,6 +167,9 @@ public static class Builder extends WithJsonObjectBuilderBase ObjectBuilder { private String node; + @Nullable + private String relocatingNode; + private Boolean primary; private String state; @@ -155,6 +178,7 @@ public Builder() { } private Builder(ShardSegmentRouting instance) { this.node = instance.node; + this.relocatingNode = instance.relocatingNode; this.primary = instance.primary; this.state = instance.state; @@ -169,6 +193,17 @@ public final Builder node(String value) { return this; } + /** + * The node ID of the node the shard is relocating to. Only returned while the + * shard is relocating. + *

+ * API name: {@code relocating_node} + */ + public final Builder relocatingNode(@Nullable String value) { + this.relocatingNode = value; + return this; + } + /** * Required - If true, the shard is a primary shard. *

@@ -225,6 +260,7 @@ public Builder rebuild() { protected static void setupShardSegmentRoutingDeserializer(ObjectDeserializer op) { op.add(Builder::node, JsonpDeserializer.stringDeserializer(), "node"); + op.add(Builder::relocatingNode, JsonpDeserializer.stringDeserializer(), "relocating_node"); op.add(Builder::primary, JsonpDeserializer.booleanDeserializer(), "primary"); op.add(Builder::state, JsonpDeserializer.stringDeserializer(), "state"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/stats/IndexStats.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/stats/IndexStats.java index bcd8a77046..7245e46104 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/stats/IndexStats.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/stats/IndexStats.java @@ -36,6 +36,8 @@ import co.elastic.clients.elasticsearch._types.StoreStats; import co.elastic.clients.elasticsearch._types.TranslogStats; import co.elastic.clients.elasticsearch._types.WarmerStats; +import co.elastic.clients.elasticsearch.cluster.stats.DenseVectorStats; +import co.elastic.clients.elasticsearch.cluster.stats.SparseVectorStats; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -77,6 +79,9 @@ public class IndexStats implements JsonpSerializable { @Nullable private final CompletionStats completion; + @Nullable + private final DenseVectorStats denseVector; + @Nullable private final DocStats docs; @@ -116,6 +121,9 @@ public class IndexStats implements JsonpSerializable { @Nullable private final SegmentsStats segments; + @Nullable + private final SparseVectorStats sparseVector; + @Nullable private final StoreStats store; @@ -136,6 +144,7 @@ public class IndexStats implements JsonpSerializable { private IndexStats(Builder builder) { this.completion = builder.completion; + this.denseVector = builder.denseVector; this.docs = builder.docs; this.fielddata = builder.fielddata; this.flush = builder.flush; @@ -149,6 +158,7 @@ private IndexStats(Builder builder) { this.requestCache = builder.requestCache; this.search = builder.search; this.segments = builder.segments; + this.sparseVector = builder.sparseVector; this.store = builder.store; this.translog = builder.translog; this.warmer = builder.warmer; @@ -171,6 +181,16 @@ public final CompletionStats completion() { return this.completion; } + /** + * Contains statistics about the dense vectors in the index. + *

+ * API name: {@code dense_vector} + */ + @Nullable + public final DenseVectorStats denseVector() { + return this.denseVector; + } + /** * Contains statistics about documents across all primary shards assigned to the * node. @@ -305,6 +325,16 @@ public final SegmentsStats segments() { return this.segments; } + /** + * Contains statistics about the sparse vectors in the index. + *

+ * API name: {@code sparse_vector} + */ + @Nullable + public final SparseVectorStats sparseVector() { + return this.sparseVector; + } + /** * Contains statistics about the size of shards assigned to the node. *

@@ -366,6 +396,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("completion"); this.completion.serialize(generator, mapper); + } + if (this.denseVector != null) { + generator.writeKey("dense_vector"); + this.denseVector.serialize(generator, mapper); + } if (this.docs != null) { generator.writeKey("docs"); @@ -431,6 +466,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("segments"); this.segments.serialize(generator, mapper); + } + if (this.sparseVector != null) { + generator.writeKey("sparse_vector"); + this.sparseVector.serialize(generator, mapper); + } if (this.store != null) { generator.writeKey("store"); @@ -475,6 +515,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private CompletionStats completion; + @Nullable + private DenseVectorStats denseVector; + @Nullable private DocStats docs; @@ -514,6 +557,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private SegmentsStats segments; + @Nullable + private SparseVectorStats sparseVector; + @Nullable private StoreStats store; @@ -533,6 +579,7 @@ public Builder() { } private Builder(IndexStats instance) { this.completion = instance.completion; + this.denseVector = instance.denseVector; this.docs = instance.docs; this.fielddata = instance.fielddata; this.flush = instance.flush; @@ -546,6 +593,7 @@ private Builder(IndexStats instance) { this.requestCache = instance.requestCache; this.search = instance.search; this.segments = instance.segments; + this.sparseVector = instance.sparseVector; this.store = instance.store; this.translog = instance.translog; this.warmer = instance.warmer; @@ -572,6 +620,25 @@ public final Builder completion(Function + * API name: {@code dense_vector} + */ + public final Builder denseVector(@Nullable DenseVectorStats value) { + this.denseVector = value; + return this; + } + + /** + * Contains statistics about the dense vectors in the index. + *

+ * API name: {@code dense_vector} + */ + public final Builder denseVector(Function> fn) { + return this.denseVector(fn.apply(new DenseVectorStats.Builder()).build()); + } + /** * Contains statistics about documents across all primary shards assigned to the * node. @@ -827,6 +894,25 @@ public final Builder segments(Function + * API name: {@code sparse_vector} + */ + public final Builder sparseVector(@Nullable SparseVectorStats value) { + this.sparseVector = value; + return this; + } + + /** + * Contains statistics about the sparse vectors in the index. + *

+ * API name: {@code sparse_vector} + */ + public final Builder sparseVector(Function> fn) { + return this.sparseVector(fn.apply(new SparseVectorStats.Builder()).build()); + } + /** * Contains statistics about the size of shards assigned to the node. *

@@ -949,6 +1035,7 @@ public Builder rebuild() { protected static void setupIndexStatsDeserializer(ObjectDeserializer op) { op.add(Builder::completion, CompletionStats._DESERIALIZER, "completion"); + op.add(Builder::denseVector, DenseVectorStats._DESERIALIZER, "dense_vector"); op.add(Builder::docs, DocStats._DESERIALIZER, "docs"); op.add(Builder::fielddata, FielddataStats._DESERIALIZER, "fielddata"); op.add(Builder::flush, FlushStats._DESERIALIZER, "flush"); @@ -962,6 +1049,7 @@ protected static void setupIndexStatsDeserializer(ObjectDeserializer*). + * Wildcard patterns that match both data streams and indices return an error. *

* API name: {@code index} */ @@ -166,6 +167,7 @@ public final String index() { /** * Data streams or indices for the action. Supports wildcards (*). + * Wildcard patterns that match both data streams and indices return an error. *

* API name: {@code indices} */ @@ -443,6 +445,7 @@ public final Builder filter(QueryVariant value) { /** * Data stream or index for the action. Supports wildcards (*). + * Wildcard patterns that match both data streams and indices return an error. *

* API name: {@code index} */ @@ -453,6 +456,7 @@ public final Builder index(@Nullable String value) { /** * Data streams or indices for the action. Supports wildcards (*). + * Wildcard patterns that match both data streams and indices return an error. *

* API name: {@code indices} *

@@ -465,6 +469,7 @@ public final Builder indices(List list) { /** * Data streams or indices for the action. Supports wildcards (*). + * Wildcard patterns that match both data streams and indices return an error. *

* API name: {@code indices} *

diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/AliasActionResult.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/AliasActionResult.java new file mode 100644 index 0000000000..e5d08d2651 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/AliasActionResult.java @@ -0,0 +1,255 @@ +/* + * 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.indices.update_aliases; + +import co.elastic.clients.elasticsearch._types.ErrorCause; +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.JsonpUtils; +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.util.Objects; +import java.util.function.Function; +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: indices.update_aliases.AliasActionResult + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class AliasActionResult implements JsonpSerializable { + private final AliasActionSummary action; + + private final int status; + + @Nullable + private final ErrorCause error; + + // --------------------------------------------------------------------------------------------- + + private AliasActionResult(Builder builder) { + + this.action = ApiTypeHelper.requireNonNull(builder.action, this, "action"); + this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status", 0); + this.error = builder.error; + + } + + public static AliasActionResult of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The action this result describes. + *

+ * API name: {@code action} + */ + public final AliasActionSummary action() { + return this.action; + } + + /** + * Required - HTTP status for this action. 200 when the action + * succeeds. + *

+ * API name: {@code status} + */ + public final int status() { + return this.status; + } + + /** + * Cause of the failure. Returned only when this action fails. + *

+ * API name: {@code error} + */ + @Nullable + public final ErrorCause error() { + return this.error; + } + + /** + * 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("action"); + this.action.serialize(generator, mapper); + + generator.writeKey("status"); + generator.write(this.status); + + if (this.error != null) { + generator.writeKey("error"); + this.error.serialize(generator, mapper); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link AliasActionResult}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private AliasActionSummary action; + + private Integer status; + + @Nullable + private ErrorCause error; + + public Builder() { + } + private Builder(AliasActionResult instance) { + this.action = instance.action; + this.status = instance.status; + this.error = instance.error; + + } + /** + * Required - The action this result describes. + *

+ * API name: {@code action} + */ + public final Builder action(AliasActionSummary value) { + this.action = value; + return this; + } + + /** + * Required - The action this result describes. + *

+ * API name: {@code action} + */ + public final Builder action(Function> fn) { + return this.action(fn.apply(new AliasActionSummary.Builder()).build()); + } + + /** + * Required - HTTP status for this action. 200 when the action + * succeeds. + *

+ * API name: {@code status} + */ + public final Builder status(int value) { + this.status = value; + return this; + } + + /** + * Cause of the failure. Returned only when this action fails. + *

+ * API name: {@code error} + */ + public final Builder error(@Nullable ErrorCause value) { + this.error = value; + return this; + } + + /** + * Cause of the failure. Returned only when this action fails. + *

+ * API name: {@code error} + */ + public final Builder error(Function> fn) { + return this.error(fn.apply(new ErrorCause.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link AliasActionResult}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public AliasActionResult build() { + _checkSingleUse(); + + return new AliasActionResult(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link AliasActionResult} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, AliasActionResult::setupAliasActionResultDeserializer); + + protected static void setupAliasActionResultDeserializer(ObjectDeserializer op) { + + op.add(Builder::action, AliasActionSummary._DESERIALIZER, "action"); + op.add(Builder::status, JsonpDeserializer.integerDeserializer(), "status"); + op.add(Builder::error, ErrorCause._DESERIALIZER, "error"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/AliasActionSummary.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/AliasActionSummary.java new file mode 100644 index 0000000000..659bda1902 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/AliasActionSummary.java @@ -0,0 +1,275 @@ +/* + * 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.indices.update_aliases; + +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.JsonpUtils; +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.String; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: indices.update_aliases.AliasActionSummary + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class AliasActionSummary implements JsonpSerializable { + private final AliasActionType type; + + private final List indices; + + private final List aliases; + + // --------------------------------------------------------------------------------------------- + + private AliasActionSummary(Builder builder) { + + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); + this.aliases = ApiTypeHelper.unmodifiableRequired(builder.aliases, this, "aliases"); + + } + + public static AliasActionSummary of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The action that was applied. + *

+ * API name: {@code type} + */ + public final AliasActionType type() { + return this.type; + } + + /** + * Required - Resolved data streams or indices for the action. + *

+ * API name: {@code indices} + */ + public final List indices() { + return this.indices; + } + + /** + * Required - Aliases for the action. + *

+ * API name: {@code aliases} + */ + public final List aliases() { + return this.aliases; + } + + /** + * 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("type"); + this.type.serialize(generator, mapper); + if (ApiTypeHelper.isDefined(this.indices)) { + generator.writeKey("indices"); + generator.writeStartArray(); + for (String item0 : this.indices) { + generator.write(item0); + + } + generator.writeEnd(); + + } + if (ApiTypeHelper.isDefined(this.aliases)) { + generator.writeKey("aliases"); + generator.writeStartArray(); + for (String item0 : this.aliases) { + generator.write(item0); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link AliasActionSummary}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private AliasActionType type; + + private List indices; + + private List aliases; + + public Builder() { + } + private Builder(AliasActionSummary instance) { + this.type = instance.type; + this.indices = instance.indices; + this.aliases = instance.aliases; + + } + /** + * Required - The action that was applied. + *

+ * API name: {@code type} + */ + public final Builder type(AliasActionType value) { + this.type = value; + return this; + } + + /** + * Required - Resolved data streams or indices for the action. + *

+ * API name: {@code indices} + *

+ * Adds all elements of list to indices. + */ + public final Builder indices(List list) { + this.indices = _listAddAll(this.indices, list); + return this; + } + + /** + * Required - Resolved data streams or indices for the action. + *

+ * API name: {@code indices} + *

+ * Adds one or more values to indices. + */ + public final Builder indices(String value, String... values) { + this.indices = _listAdd(this.indices, value, values); + return this; + } + + /** + * Required - Aliases for the action. + *

+ * API name: {@code aliases} + *

+ * Adds all elements of list to aliases. + */ + public final Builder aliases(List list) { + this.aliases = _listAddAll(this.aliases, list); + return this; + } + + /** + * Required - Aliases for the action. + *

+ * API name: {@code aliases} + *

+ * Adds one or more values to aliases. + */ + public final Builder aliases(String value, String... values) { + this.aliases = _listAdd(this.aliases, value, values); + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link AliasActionSummary}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public AliasActionSummary build() { + _checkSingleUse(); + + return new AliasActionSummary(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link AliasActionSummary} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, AliasActionSummary::setupAliasActionSummaryDeserializer); + + protected static void setupAliasActionSummaryDeserializer(ObjectDeserializer op) { + + op.add(Builder::type, AliasActionType._DESERIALIZER, "type"); + op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "indices"); + op.add(Builder::aliases, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "aliases"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/AliasActionType.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/AliasActionType.java new file mode 100644 index 0000000000..bb0bdd68a0 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/AliasActionType.java @@ -0,0 +1,69 @@ +/* + * 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.indices.update_aliases; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum AliasActionType implements JsonEnum { + Add("add"), + + Remove("remove"), + + RemoveIndex("remove_index"), + + ; + + private final String jsonValue; + + AliasActionType(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + AliasActionType.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/IndicesUpdateAliasesResponseBody.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/IndicesUpdateAliasesResponseBody.java new file mode 100644 index 0000000000..14d9332d5a --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/update_aliases/IndicesUpdateAliasesResponseBody.java @@ -0,0 +1,154 @@ +/* + * 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.indices.update_aliases; + +import co.elastic.clients.elasticsearch.indices.AliasesResponseBody; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +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.util.List; +import java.util.Objects; +import java.util.function.Function; +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: indices.update_aliases.IndicesUpdateAliasesResponseBody + +/** + * + * @see API + * specification + */ + +public abstract class IndicesUpdateAliasesResponseBody extends AliasesResponseBody { + private final List actionResults; + + // --------------------------------------------------------------------------------------------- + + protected IndicesUpdateAliasesResponseBody(AbstractBuilder builder) { + super(builder); + + this.actionResults = ApiTypeHelper.unmodifiable(builder.actionResults); + + } + + /** + * Results for each action in the request. Returned only when + * errors is true. + *

+ * API name: {@code action_results} + */ + public final List actionResults() { + return this.actionResults; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + if (ApiTypeHelper.isDefined(this.actionResults)) { + generator.writeKey("action_results"); + generator.writeStartArray(); + for (AliasActionResult item0 : this.actionResults) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + public abstract static class AbstractBuilder> + extends + AliasesResponseBody.AbstractBuilder { + @Nullable + private List actionResults; + + /** + * Results for each action in the request. Returned only when + * errors is true. + *

+ * API name: {@code action_results} + *

+ * Adds all elements of list to actionResults. + */ + public final BuilderT actionResults(List list) { + this.actionResults = _listAddAll(this.actionResults, list); + return self(); + } + + /** + * Results for each action in the request. Returned only when + * errors is true. + *

+ * API name: {@code action_results} + *

+ * Adds one or more values to actionResults. + */ + public final BuilderT actionResults(AliasActionResult value, AliasActionResult... values) { + this.actionResults = _listAdd(this.actionResults, value, values); + return self(); + } + + /** + * Results for each action in the request. Returned only when + * errors is true. + *

+ * API name: {@code action_results} + *

+ * Adds a value to actionResults using a builder lambda. + */ + public final BuilderT actionResults(Function> fn) { + return actionResults(fn.apply(new AliasActionResult.Builder()).build()); + } + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupIndicesUpdateAliasesResponseBodyDeserializer( + ObjectDeserializer op) { + AliasesResponseBody.setupAliasesResponseBodyDeserializer(op); + op.add(AbstractBuilder::actionResults, JsonpDeserializer.arrayDeserializer(AliasActionResult._DESERIALIZER), + "action_results"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CacheControl.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CacheControl.java new file mode 100644 index 0000000000..4f4954806c --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CacheControl.java @@ -0,0 +1,220 @@ +/* + * 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.inference; + +import co.elastic.clients.elasticsearch._types.Time; +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.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +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: inference._types.CacheControl + +/** + * The prompt caching configuration to use for the completion request. Currently + * supported only for elastic provider. + * + * @see API + * specification + */ +@JsonpDeserializable +public class CacheControl implements JsonpSerializable { + @Nullable + private final String type; + + @Nullable + private final Time ttl; + + // --------------------------------------------------------------------------------------------- + + private CacheControl(Builder builder) { + + this.type = builder.type; + this.ttl = builder.ttl; + + } + + public static CacheControl of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The type of cache control, for example ephemeral. + *

+ * API name: {@code type} + */ + @Nullable + public final String type() { + return this.type; + } + + /** + * The time to live of the cached content, for example 1h. + *

+ * API name: {@code ttl} + */ + @Nullable + public final Time ttl() { + return this.ttl; + } + + /** + * 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 (this.type != null) { + generator.writeKey("type"); + generator.write(this.type); + + } + if (this.ttl != null) { + generator.writeKey("ttl"); + this.ttl.serialize(generator, mapper); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link CacheControl}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable + private String type; + + @Nullable + private Time ttl; + + public Builder() { + } + private Builder(CacheControl instance) { + this.type = instance.type; + this.ttl = instance.ttl; + + } + /** + * The type of cache control, for example ephemeral. + *

+ * API name: {@code type} + */ + public final Builder type(@Nullable String value) { + this.type = value; + return this; + } + + /** + * The time to live of the cached content, for example 1h. + *

+ * API name: {@code ttl} + */ + public final Builder ttl(@Nullable Time value) { + this.ttl = value; + return this; + } + + /** + * The time to live of the cached content, for example 1h. + *

+ * API name: {@code ttl} + */ + public final Builder ttl(Function> fn) { + return this.ttl(fn.apply(new Time.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link CacheControl}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public CacheControl build() { + _checkSingleUse(); + + return new CacheControl(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link CacheControl} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + CacheControl::setupCacheControlDeserializer); + + protected static void setupCacheControlDeserializer(ObjectDeserializer op) { + + op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + op.add(Builder::ttl, Time._DESERIALIZER, "ttl"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChoiceDecisionAnswer.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChoiceDecisionAnswer.java new file mode 100644 index 0000000000..41a1e95b8d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChoiceDecisionAnswer.java @@ -0,0 +1,278 @@ +/* + * 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.inference; + +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.JsonpUtils; +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.Double; +import java.lang.String; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: inference._types.ChoiceDecisionAnswer + +/** + * The answer to a choice question. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ChoiceDecisionAnswer implements DecisionAnswerVariant, JsonpSerializable { + private final String choice; + + private final List probabilities; + + private final double confidence; + + // --------------------------------------------------------------------------------------------- + + private ChoiceDecisionAnswer(Builder builder) { + + this.choice = ApiTypeHelper.requireNonNull(builder.choice, this, "choice"); + this.probabilities = ApiTypeHelper.unmodifiableRequired(builder.probabilities, this, "probabilities"); + this.confidence = ApiTypeHelper.requireNonNull(builder.confidence, this, "confidence", 0); + + } + + public static ChoiceDecisionAnswer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * DecisionAnswer variant kind. + */ + @Override + public DecisionAnswer.Kind _decisionAnswerKind() { + return DecisionAnswer.Kind.Choice; + } + + /** + * Required - The chosen option. + *

+ * API name: {@code choice} + */ + public final String choice() { + return this.choice; + } + + /** + * Required - The probability of each option. + *

+ * API name: {@code probabilities} + */ + public final List probabilities() { + return this.probabilities; + } + + /** + * Required - The confidence in the chosen option. + *

+ * API name: {@code confidence} + */ + public final double confidence() { + return this.confidence; + } + + /** + * 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.write("type", "choice"); + + generator.writeKey("choice"); + generator.write(this.choice); + + if (ApiTypeHelper.isDefined(this.probabilities)) { + generator.writeKey("probabilities"); + generator.writeStartArray(); + for (ChoiceDecisionProbability item0 : this.probabilities) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("confidence"); + generator.write(this.confidence); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChoiceDecisionAnswer}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String choice; + + private List probabilities; + + private Double confidence; + + public Builder() { + } + private Builder(ChoiceDecisionAnswer instance) { + this.choice = instance.choice; + this.probabilities = instance.probabilities; + this.confidence = instance.confidence; + + } + /** + * Required - The chosen option. + *

+ * API name: {@code choice} + */ + public final Builder choice(String value) { + this.choice = value; + return this; + } + + /** + * Required - The probability of each option. + *

+ * API name: {@code probabilities} + *

+ * Adds all elements of list to probabilities. + */ + public final Builder probabilities(List list) { + this.probabilities = _listAddAll(this.probabilities, list); + return this; + } + + /** + * Required - The probability of each option. + *

+ * API name: {@code probabilities} + *

+ * Adds one or more values to probabilities. + */ + public final Builder probabilities(ChoiceDecisionProbability value, ChoiceDecisionProbability... values) { + this.probabilities = _listAdd(this.probabilities, value, values); + return this; + } + + /** + * Required - The probability of each option. + *

+ * API name: {@code probabilities} + *

+ * Adds a value to probabilities using a builder lambda. + */ + public final Builder probabilities( + Function> fn) { + return probabilities(fn.apply(new ChoiceDecisionProbability.Builder()).build()); + } + + /** + * Required - The confidence in the chosen option. + *

+ * API name: {@code confidence} + */ + public final Builder confidence(double value) { + this.confidence = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ChoiceDecisionAnswer}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChoiceDecisionAnswer build() { + _checkSingleUse(); + + return new ChoiceDecisionAnswer(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChoiceDecisionAnswer} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ChoiceDecisionAnswer::setupChoiceDecisionAnswerDeserializer); + + protected static void setupChoiceDecisionAnswerDeserializer(ObjectDeserializer op) { + + op.add(Builder::choice, JsonpDeserializer.stringDeserializer(), "choice"); + op.add(Builder::probabilities, JsonpDeserializer.arrayDeserializer(ChoiceDecisionProbability._DESERIALIZER), + "probabilities"); + op.add(Builder::confidence, JsonpDeserializer.doubleDeserializer(), "confidence"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChoiceDecisionProbability.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChoiceDecisionProbability.java new file mode 100644 index 0000000000..08687f4771 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChoiceDecisionProbability.java @@ -0,0 +1,203 @@ +/* + * 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.inference; + +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.JsonpUtils; +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.Double; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +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: inference._types.ChoiceDecisionProbability + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ChoiceDecisionProbability implements JsonpSerializable { + private final String value; + + private final double probability; + + // --------------------------------------------------------------------------------------------- + + private ChoiceDecisionProbability(Builder builder) { + + this.value = ApiTypeHelper.requireNonNull(builder.value, this, "value"); + this.probability = ApiTypeHelper.requireNonNull(builder.probability, this, "probability", 0); + + } + + public static ChoiceDecisionProbability of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The option. + *

+ * API name: {@code value} + */ + public final String value() { + return this.value; + } + + /** + * Required - The probability of the option. + *

+ * API name: {@code probability} + */ + public final double probability() { + return this.probability; + } + + /** + * 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("value"); + generator.write(this.value); + + generator.writeKey("probability"); + generator.write(this.probability); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChoiceDecisionProbability}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String value; + + private Double probability; + + public Builder() { + } + private Builder(ChoiceDecisionProbability instance) { + this.value = instance.value; + this.probability = instance.probability; + + } + /** + * Required - The option. + *

+ * API name: {@code value} + */ + public final Builder value(String value) { + this.value = value; + return this; + } + + /** + * Required - The probability of the option. + *

+ * API name: {@code probability} + */ + public final Builder probability(double value) { + this.probability = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ChoiceDecisionProbability}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChoiceDecisionProbability build() { + _checkSingleUse(); + + return new ChoiceDecisionProbability(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChoiceDecisionProbability} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ChoiceDecisionProbability::setupChoiceDecisionProbabilityDeserializer); + + protected static void setupChoiceDecisionProbabilityDeserializer( + ObjectDeserializer op) { + + op.add(Builder::value, JsonpDeserializer.stringDeserializer(), "value"); + op.add(Builder::probability, JsonpDeserializer.doubleDeserializer(), "probability"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionAnswer.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionAnswer.java new file mode 100644 index 0000000000..84ea2a4037 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionAnswer.java @@ -0,0 +1,317 @@ +/* + * 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.inference; + +import co.elastic.clients.json.JsonData; +import co.elastic.clients.json.JsonEnum; +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.JsonpUtils; +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.OpenTaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Object; +import java.util.Objects; +import java.util.function.Function; +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: inference._types.DecisionAnswer + +/** + * The answer to a single question of a decision request. The type of the answer + * matches the type of the question it answers. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DecisionAnswer implements OpenTaggedUnion, JsonpSerializable { + + /** + * {@link DecisionAnswer} variant kinds. + * + * @see API + * specification + */ + + public enum Kind implements JsonEnum { + Choice("choice"), + + Predicate("predicate"), + + Score("score"), + + /** A custom {@code DecisionAnswer} defined by a plugin */ + _Custom(null) + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + public DecisionAnswer(DecisionAnswerVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._decisionAnswerKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + this._customKind = null; + + } + + private DecisionAnswer(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + this._customKind = builder._customKind; + + } + + public static DecisionAnswer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Build a custom plugin-defined {@code DecisionAnswer}, given its kind and some + * JSON data + */ + public DecisionAnswer(String kind, JsonData value) { + this._kind = Kind._Custom; + this._value = value; + this._customKind = kind; + } + + /** + * Is this variant instance of kind {@code choice}? + */ + public boolean isChoice() { + return _kind == Kind.Choice; + } + + /** + * Get the {@code choice} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code choice} kind. + */ + public ChoiceDecisionAnswer choice() { + return TaggedUnionUtils.get(this, Kind.Choice); + } + + /** + * Is this variant instance of kind {@code predicate}? + */ + public boolean isPredicate() { + return _kind == Kind.Predicate; + } + + /** + * Get the {@code predicate} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code predicate} kind. + */ + public PredicateDecisionAnswer predicate() { + return TaggedUnionUtils.get(this, Kind.Predicate); + } + + /** + * Is this variant instance of kind {@code score}? + */ + public boolean isScore() { + return _kind == Kind.Score; + } + + /** + * Get the {@code score} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code score} kind. + */ + public ScoreDecisionAnswer score() { + return TaggedUnionUtils.get(this, Kind.Score); + } + + @Nullable + private final String _customKind; + + /** + * Is this a custom {@code DecisionAnswer} defined by a plugin? + */ + public boolean _isCustom() { + return _kind == Kind._Custom; + } + + /** + * Get the actual kind when {@code _kind()} equals {@link Kind#_Custom} + * (plugin-defined variant). + */ + @Nullable + public final String _customKind() { + return _customKind; + } + + /** + * Get the custom plugin-defined variant value. + * + * @throws IllegalStateException + * if the current variant is not {@link Kind#_Custom}. + */ + public JsonData _custom() { + return TaggedUnionUtils.get(this, Kind._Custom); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + + mapper.serialize(_value, generator); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + private String _customKind; + + @Override + protected Builder self() { + return this; + } + public ObjectBuilder choice(ChoiceDecisionAnswer v) { + this._kind = Kind.Choice; + this._value = v; + return this; + } + + public ObjectBuilder choice( + Function> fn) { + return this.choice(fn.apply(new ChoiceDecisionAnswer.Builder()).build()); + } + + public ObjectBuilder predicate(PredicateDecisionAnswer v) { + this._kind = Kind.Predicate; + this._value = v; + return this; + } + + public ObjectBuilder predicate( + Function> fn) { + return this.predicate(fn.apply(new PredicateDecisionAnswer.Builder()).build()); + } + + public ObjectBuilder score(ScoreDecisionAnswer v) { + this._kind = Kind.Score; + this._value = v; + return this; + } + + public ObjectBuilder score( + Function> fn) { + return this.score(fn.apply(new ScoreDecisionAnswer.Builder()).build()); + } + + /** + * Define this {@code DecisionAnswer} as a plugin-defined variant. + * + * @param name + * the plugin-defined identifier + * @param data + * the data for this custom {@code DecisionAnswer}. It is converted + * internally to {@link JsonData}. + */ + public ObjectBuilder _custom(String name, Object data) { + this._kind = Kind._Custom; + this._customKind = name; + this._value = JsonData.of(data); + return this; + } + + public DecisionAnswer build() { + _checkSingleUse(); + return new DecisionAnswer(this); + } + + } + + protected static void setupDecisionAnswerDeserializer(ObjectDeserializer op) { + + op.add(Builder::choice, ChoiceDecisionAnswer._DESERIALIZER, "choice"); + op.add(Builder::predicate, PredicateDecisionAnswer._DESERIALIZER, "predicate"); + op.add(Builder::score, ScoreDecisionAnswer._DESERIALIZER, "score"); + + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + JsonpUtils.ensureCustomVariantsAllowed(parser, mapper); + builder._custom(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); + + op.setTypeProperty("type", null); + + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + DecisionAnswer::setupDecisionAnswerDeserializer, Builder::build); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionAnswerBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionAnswerBuilders.java new file mode 100644 index 0000000000..5cd7fbd184 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionAnswerBuilders.java @@ -0,0 +1,103 @@ +/* + * 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.inference; + +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link DecisionAnswer} variants. + */ +public class DecisionAnswerBuilders { + private DecisionAnswerBuilders() { + } + + /** + * Creates a builder for the {@link ChoiceDecisionAnswer choice} + * {@code DecisionAnswer} variant. + */ + public static ChoiceDecisionAnswer.Builder choice() { + return new ChoiceDecisionAnswer.Builder(); + } + + /** + * Creates a DecisionAnswer of the {@link ChoiceDecisionAnswer choice} + * {@code DecisionAnswer} variant. + */ + public static DecisionAnswer choice( + Function> fn) { + DecisionAnswer.Builder builder = new DecisionAnswer.Builder(); + builder.choice(fn.apply(new ChoiceDecisionAnswer.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link PredicateDecisionAnswer predicate} + * {@code DecisionAnswer} variant. + */ + public static PredicateDecisionAnswer.Builder predicate() { + return new PredicateDecisionAnswer.Builder(); + } + + /** + * Creates a DecisionAnswer of the {@link PredicateDecisionAnswer predicate} + * {@code DecisionAnswer} variant. + */ + public static DecisionAnswer predicate( + Function> fn) { + DecisionAnswer.Builder builder = new DecisionAnswer.Builder(); + builder.predicate(fn.apply(new PredicateDecisionAnswer.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link ScoreDecisionAnswer score} + * {@code DecisionAnswer} variant. + */ + public static ScoreDecisionAnswer.Builder score() { + return new ScoreDecisionAnswer.Builder(); + } + + /** + * Creates a DecisionAnswer of the {@link ScoreDecisionAnswer score} + * {@code DecisionAnswer} variant. + */ + public static DecisionAnswer score(Function> fn) { + DecisionAnswer.Builder builder = new DecisionAnswer.Builder(); + builder.score(fn.apply(new ScoreDecisionAnswer.Builder()).build()); + return builder.build(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionAnswerVariant.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionAnswerVariant.java new file mode 100644 index 0000000000..cd31af1673 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionAnswerVariant.java @@ -0,0 +1,50 @@ +/* + * 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.inference; + +import co.elastic.clients.json.JsonpSerializable; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Base interface for {@link DecisionAnswer} variants. + */ +public interface DecisionAnswerVariant extends JsonpSerializable { + + DecisionAnswer.Kind _decisionAnswerKind(); + + default DecisionAnswer _toDecisionAnswer() { + return new DecisionAnswer(this); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionInferenceResult.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionInferenceResult.java new file mode 100644 index 0000000000..758225ed37 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionInferenceResult.java @@ -0,0 +1,133 @@ +/* + * 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.inference; + +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.JsonpUtils; +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.util.Objects; +import java.util.function.Function; +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: inference._types.DecisionInferenceResult + +/** + * Defines the response for a decision request. + * + * @see API + * specification + */ + +public abstract class DecisionInferenceResult implements JsonpSerializable { + private final DecisionResult decision; + + // --------------------------------------------------------------------------------------------- + + protected DecisionInferenceResult(AbstractBuilder builder) { + + this.decision = ApiTypeHelper.requireNonNull(builder.decision, this, "decision"); + + } + + /** + * Required - API name: {@code decision} + */ + public final DecisionResult decision() { + return this.decision; + } + + /** + * 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("decision"); + this.decision.serialize(generator, mapper); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + private DecisionResult decision; + + /** + * Required - API name: {@code decision} + */ + public final BuilderT decision(DecisionResult value) { + this.decision = value; + return self(); + } + + /** + * Required - API name: {@code decision} + */ + public final BuilderT decision(Function> fn) { + return this.decision(fn.apply(new DecisionResult.Builder()).build()); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupDecisionInferenceResultDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::decision, DecisionResult._DESERIALIZER, "decision"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionRequest.java new file mode 100644 index 0000000000..ab7c6a9835 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionRequest.java @@ -0,0 +1,420 @@ +/* + * 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.inference; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.RequestBase; +import co.elastic.clients.elasticsearch._types.Time; +import co.elastic.clients.elasticsearch.inference.decision.DecisionInput; +import co.elastic.clients.elasticsearch.inference.decision.DecisionTaskSettings; +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.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.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: inference.decision.Request + +/** + * Perform decision inference on the service. + *

+ * Answer a set of named questions about an input, such as whether a customer is + * complaining, which team should handle a request, or how angry a customer is. + * The questions are defined in the task settings of the inference endpoint, and + * can be replaced for a single request through task_settings. + *

+ *

+ * info Only the elastic service currently supports the + * decision task. + *

+ *
+ * + * @see API + * specification + */ +@JsonpDeserializable +public class DecisionRequest extends RequestBase implements JsonpSerializable { + private final String inferenceId; + + private final DecisionInput input; + + @Nullable + private final DecisionTaskSettings taskSettings; + + @Nullable + private final Time timeout; + + // --------------------------------------------------------------------------------------------- + + private DecisionRequest(Builder builder) { + + this.inferenceId = ApiTypeHelper.requireNonNull(builder.inferenceId, this, "inferenceId"); + this.input = ApiTypeHelper.requireNonNull(builder.input, this, "input"); + this.taskSettings = builder.taskSettings; + this.timeout = builder.timeout; + + } + + public static DecisionRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The unique identifier for the inference endpoint. + *

+ * API name: {@code inference_id} + */ + public final String inferenceId() { + return this.inferenceId; + } + + /** + * Required - The input to answer the questions about. It can be specified as a + * string, or as an object. The object form additionally allows specifying + * images. + *

+ * string example: + * + *

+	 * "input": "I was charged twice for my order and nobody answers my emails."
+	 * 
+	 * 
+ *

+ * object example: + * + *

+	 * "input": {
+	 *   "type": "image",
+	 *   "format": "base64",
+	 *   "value": "data:image/jpeg;base64,..."
+	 * }
+	 * 
+	 * 
+ *

+ * API name: {@code input} + */ + public final DecisionInput input() { + return this.input; + } + + /** + * Task settings for the individual inference request. These settings override + * the task settings specified when creating the inference endpoint. + *

+ * API name: {@code task_settings} + */ + @Nullable + public final DecisionTaskSettings taskSettings() { + return this.taskSettings; + } + + /** + * The amount of time to wait for the inference request to complete. + *

+ * API name: {@code timeout} + */ + @Nullable + public final Time timeout() { + return this.timeout; + } + + /** + * 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("input"); + this.input.serialize(generator, mapper); + + if (this.taskSettings != null) { + generator.writeKey("task_settings"); + this.taskSettings.serialize(generator, mapper); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DecisionRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder implements ObjectBuilder { + private String inferenceId; + + private DecisionInput input; + + @Nullable + private DecisionTaskSettings taskSettings; + + @Nullable + private Time timeout; + + public Builder() { + } + private Builder(DecisionRequest instance) { + this.inferenceId = instance.inferenceId; + this.input = instance.input; + this.taskSettings = instance.taskSettings; + this.timeout = instance.timeout; + + } + /** + * Required - The unique identifier for the inference endpoint. + *

+ * API name: {@code inference_id} + */ + public final Builder inferenceId(String value) { + this.inferenceId = value; + return this; + } + + /** + * Required - The input to answer the questions about. It can be specified as a + * string, or as an object. The object form additionally allows specifying + * images. + *

+ * string example: + * + *

+		 * "input": "I was charged twice for my order and nobody answers my emails."
+		 * 
+		 * 
+ *

+ * object example: + * + *

+		 * "input": {
+		 *   "type": "image",
+		 *   "format": "base64",
+		 *   "value": "data:image/jpeg;base64,..."
+		 * }
+		 * 
+		 * 
+ *

+ * API name: {@code input} + */ + public final Builder input(DecisionInput value) { + this.input = value; + return this; + } + + /** + * Required - The input to answer the questions about. It can be specified as a + * string, or as an object. The object form additionally allows specifying + * images. + *

+ * string example: + * + *

+		 * "input": "I was charged twice for my order and nobody answers my emails."
+		 * 
+		 * 
+ *

+ * object example: + * + *

+		 * "input": {
+		 *   "type": "image",
+		 *   "format": "base64",
+		 *   "value": "data:image/jpeg;base64,..."
+		 * }
+		 * 
+		 * 
+ *

+ * API name: {@code input} + */ + public final Builder input(Function> fn) { + return this.input(fn.apply(new DecisionInput.Builder()).build()); + } + + /** + * Task settings for the individual inference request. These settings override + * the task settings specified when creating the inference endpoint. + *

+ * API name: {@code task_settings} + */ + public final Builder taskSettings(@Nullable DecisionTaskSettings value) { + this.taskSettings = value; + return this; + } + + /** + * Task settings for the individual inference request. These settings override + * the task settings specified when creating the inference endpoint. + *

+ * API name: {@code task_settings} + */ + public final Builder taskSettings( + Function> fn) { + return this.taskSettings(fn.apply(new DecisionTaskSettings.Builder()).build()); + } + + /** + * The amount of time to wait for the inference request to complete. + *

+ * API name: {@code timeout} + */ + public final Builder timeout(@Nullable Time value) { + this.timeout = value; + return this; + } + + /** + * The amount of time to wait for the inference request to complete. + *

+ * API name: {@code timeout} + */ + public final Builder timeout(Function> fn) { + return this.timeout(fn.apply(new Time.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DecisionRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DecisionRequest build() { + _checkSingleUse(); + + return new DecisionRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DecisionRequest} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + DecisionRequest::setupDecisionRequestDeserializer); + + protected static void setupDecisionRequestDeserializer(ObjectDeserializer op) { + + op.add(Builder::input, DecisionInput._DESERIALIZER, "input"); + op.add(Builder::taskSettings, DecisionTaskSettings._DESERIALIZER, "task_settings"); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code inference.decision}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/inference.decision", + + // Request method + request -> { + return "POST"; + + }, + + // Request path + request -> { + final int _inferenceId = 1 << 0; + + int propsSet = 0; + + propsSet |= _inferenceId; + + if (propsSet == (_inferenceId)) { + StringBuilder buf = new StringBuilder(); + buf.append("/_inference"); + buf.append("/decision"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.inferenceId, buf); + return buf.toString(); + } + throw SimpleEndpoint.noPathTemplateFound("path"); + + }, + + // Path parameters + request -> { + Map params = new HashMap<>(); + final int _inferenceId = 1 << 0; + + int propsSet = 0; + + propsSet |= _inferenceId; + + if (propsSet == (_inferenceId)) { + params.put("inferenceId", request.inferenceId); + } + return params; + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.timeout != null) { + params.put("timeout", request.timeout._toJsonString()); + } + return params; + + }, SimpleEndpoint.emptyMap(), true, DecisionResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionResponse.java new file mode 100644 index 0000000000..79e11c56f5 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionResponse.java @@ -0,0 +1,106 @@ +/* + * 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.inference; + +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.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: inference.decision.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DecisionResponse extends DecisionInferenceResult { + // --------------------------------------------------------------------------------------------- + + private DecisionResponse(Builder builder) { + super(builder); + + } + + public static DecisionResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DecisionResponse}. + */ + + public static class Builder extends DecisionInferenceResult.AbstractBuilder + implements + ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DecisionResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DecisionResponse build() { + _checkSingleUse(); + + return new DecisionResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DecisionResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + DecisionResponse::setupDecisionResponseDeserializer); + + protected static void setupDecisionResponseDeserializer(ObjectDeserializer op) { + DecisionInferenceResult.setupDecisionInferenceResultDeserializer(op); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionResult.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionResult.java new file mode 100644 index 0000000000..45f279e62a --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DecisionResult.java @@ -0,0 +1,204 @@ +/* + * 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.inference; + +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.JsonpUtils; +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.String; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: inference._types.DecisionResult + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DecisionResult implements JsonpSerializable { + private final Map answers; + + // --------------------------------------------------------------------------------------------- + + private DecisionResult(Builder builder) { + + this.answers = ApiTypeHelper.unmodifiableRequired(builder.answers, this, "answers"); + + } + + public static DecisionResult of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The answers, keyed by the name of the question they answer. + *

+ * API name: {@code answers} + */ + public final Map answers() { + return this.answers; + } + + /** + * 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.answers)) { + generator.writeKey("answers"); + generator.writeStartObject(); + for (Map.Entry item0 : this.answers.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DecisionResult}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private Map answers; + + public Builder() { + } + private Builder(DecisionResult instance) { + this.answers = instance.answers; + + } + /** + * Required - The answers, keyed by the name of the question they answer. + *

+ * API name: {@code answers} + *

+ * Adds all entries of map to answers. + */ + public final Builder answers(Map map) { + this.answers = _mapPutAll(this.answers, map); + return this; + } + + /** + * Required - The answers, keyed by the name of the question they answer. + *

+ * API name: {@code answers} + *

+ * Adds an entry to answers. + */ + public final Builder answers(String key, DecisionAnswer value) { + this.answers = _mapPut(this.answers, key, value); + return this; + } + + /** + * Required - The answers, keyed by the name of the question they answer. + *

+ * API name: {@code answers} + *

+ * Adds an entry to answers using a builder lambda. + */ + public final Builder answers(String key, Function> fn) { + return answers(key, fn.apply(new DecisionAnswer.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DecisionResult}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DecisionResult build() { + _checkSingleUse(); + + return new DecisionResult(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DecisionResult} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + DecisionResult::setupDecisionResultDeserializer); + + protected static void setupDecisionResultDeserializer(ObjectDeserializer op) { + + op.add(Builder::answers, JsonpDeserializer.stringMapDeserializer(DecisionAnswer._DESERIALIZER), "answers"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionInferenceResult.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionInferenceResult.java new file mode 100644 index 0000000000..27b8e82468 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionInferenceResult.java @@ -0,0 +1,160 @@ +/* + * 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.inference; + +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.JsonpUtils; +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.util.List; +import java.util.Objects; +import java.util.function.Function; +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: inference._types.DocumentExtractionInferenceResult + +/** + * Defines the response for a document extraction request. The results are + * returned in the same order as the documents in the request. + * + * @see API + * specification + */ + +public abstract class DocumentExtractionInferenceResult implements JsonpSerializable { + private final List documentExtraction; + + // --------------------------------------------------------------------------------------------- + + protected DocumentExtractionInferenceResult(AbstractBuilder builder) { + + this.documentExtraction = ApiTypeHelper.unmodifiableRequired(builder.documentExtraction, this, + "documentExtraction"); + + } + + /** + * Required - API name: {@code document_extraction} + */ + public final List documentExtraction() { + return this.documentExtraction; + } + + /** + * 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.documentExtraction)) { + generator.writeKey("document_extraction"); + generator.writeStartArray(); + for (DocumentExtractionResult item0 : this.documentExtraction) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + private List documentExtraction; + + /** + * Required - API name: {@code document_extraction} + *

+ * Adds all elements of list to documentExtraction. + */ + public final BuilderT documentExtraction(List list) { + this.documentExtraction = _listAddAll(this.documentExtraction, list); + return self(); + } + + /** + * Required - API name: {@code document_extraction} + *

+ * Adds one or more values to documentExtraction. + */ + public final BuilderT documentExtraction(DocumentExtractionResult value, DocumentExtractionResult... values) { + this.documentExtraction = _listAdd(this.documentExtraction, value, values); + return self(); + } + + /** + * Required - API name: {@code document_extraction} + *

+ * Adds a value to documentExtraction using a builder lambda. + */ + public final BuilderT documentExtraction( + Function> fn) { + return documentExtraction(fn.apply(new DocumentExtractionResult.Builder()).build()); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupDocumentExtractionInferenceResultDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::documentExtraction, + JsonpDeserializer.arrayDeserializer(DocumentExtractionResult._DESERIALIZER), "document_extraction"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionRequest.java new file mode 100644 index 0000000000..9ffbcab178 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionRequest.java @@ -0,0 +1,529 @@ +/* + * 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.inference; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.RequestBase; +import co.elastic.clients.elasticsearch._types.Time; +import co.elastic.clients.elasticsearch.inference.document_extraction.DocumentExtractionContentObject; +import co.elastic.clients.elasticsearch.inference.document_extraction.DocumentExtractionTaskSettings; +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.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.String; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: inference.document_extraction.Request + +/** + * Perform document extraction inference on the service. + *

+ * Extract the content of documents, such as PDFs or images of documents, into a + * textual format. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DocumentExtractionRequest extends RequestBase implements JsonpSerializable { + private final String inferenceId; + + private final List input; + + @Nullable + private final DocumentExtractionTaskSettings taskSettings; + + @Nullable + private final Time timeout; + + // --------------------------------------------------------------------------------------------- + + private DocumentExtractionRequest(Builder builder) { + + this.inferenceId = ApiTypeHelper.requireNonNull(builder.inferenceId, this, "inferenceId"); + this.input = ApiTypeHelper.unmodifiableRequired(builder.input, this, "input"); + this.taskSettings = builder.taskSettings; + this.timeout = builder.timeout; + + } + + public static DocumentExtractionRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The unique identifier for the inference endpoint. + *

+ * API name: {@code inference_id} + */ + public final String inferenceId() { + return this.inferenceId; + } + + /** + * Required - The documents to extract the content from. Either a + * content object or an array of content objects. + *

+ * content object example: + * + *

+	 * "input": {
+	 *   "content": {
+	 *     "type": "pdf",
+	 *     "format": "base64",
+	 *     "value": "data:application/pdf;base64,..."
+	 *   }
+	 * }
+	 * 
+	 * 
+ *

+ * content object array example: + * + *

+	 * "input": [
+	 *   {
+	 *     "content": {
+	 *       "type": "pdf",
+	 *       "format": "base64",
+	 *       "value": "data:application/pdf;base64,..."
+	 *     }
+	 *   },
+	 *   {
+	 *     "content": {
+	 *       "type": "image",
+	 *       "format": "url",
+	 *       "value": "https://example.com/scanned-page.png"
+	 *     }
+	 *   }
+	 * ]
+	 * 
+	 * 
+ *

+ * API name: {@code input} + */ + public final List input() { + return this.input; + } + + /** + * Task settings for the individual inference request. These settings are + * specific to the task type you specified and override the task settings + * specified when initializing the service. + *

+ * API name: {@code task_settings} + */ + @Nullable + public final DocumentExtractionTaskSettings taskSettings() { + return this.taskSettings; + } + + /** + * The amount of time to wait for the inference request to complete. + *

+ * API name: {@code timeout} + */ + @Nullable + public final Time timeout() { + return this.timeout; + } + + /** + * 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.input)) { + generator.writeKey("input"); + generator.writeStartArray(); + for (DocumentExtractionContentObject item0 : this.input) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (this.taskSettings != null) { + generator.writeKey("task_settings"); + this.taskSettings.serialize(generator, mapper); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DocumentExtractionRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + private String inferenceId; + + private List input; + + @Nullable + private DocumentExtractionTaskSettings taskSettings; + + @Nullable + private Time timeout; + + public Builder() { + } + private Builder(DocumentExtractionRequest instance) { + this.inferenceId = instance.inferenceId; + this.input = instance.input; + this.taskSettings = instance.taskSettings; + this.timeout = instance.timeout; + + } + /** + * Required - The unique identifier for the inference endpoint. + *

+ * API name: {@code inference_id} + */ + public final Builder inferenceId(String value) { + this.inferenceId = value; + return this; + } + + /** + * Required - The documents to extract the content from. Either a + * content object or an array of content objects. + *

+ * content object example: + * + *

+		 * "input": {
+		 *   "content": {
+		 *     "type": "pdf",
+		 *     "format": "base64",
+		 *     "value": "data:application/pdf;base64,..."
+		 *   }
+		 * }
+		 * 
+		 * 
+ *

+ * content object array example: + * + *

+		 * "input": [
+		 *   {
+		 *     "content": {
+		 *       "type": "pdf",
+		 *       "format": "base64",
+		 *       "value": "data:application/pdf;base64,..."
+		 *     }
+		 *   },
+		 *   {
+		 *     "content": {
+		 *       "type": "image",
+		 *       "format": "url",
+		 *       "value": "https://example.com/scanned-page.png"
+		 *     }
+		 *   }
+		 * ]
+		 * 
+		 * 
+ *

+ * API name: {@code input} + *

+ * Adds all elements of list to input. + */ + public final Builder input(List list) { + this.input = _listAddAll(this.input, list); + return this; + } + + /** + * Required - The documents to extract the content from. Either a + * content object or an array of content objects. + *

+ * content object example: + * + *

+		 * "input": {
+		 *   "content": {
+		 *     "type": "pdf",
+		 *     "format": "base64",
+		 *     "value": "data:application/pdf;base64,..."
+		 *   }
+		 * }
+		 * 
+		 * 
+ *

+ * content object array example: + * + *

+		 * "input": [
+		 *   {
+		 *     "content": {
+		 *       "type": "pdf",
+		 *       "format": "base64",
+		 *       "value": "data:application/pdf;base64,..."
+		 *     }
+		 *   },
+		 *   {
+		 *     "content": {
+		 *       "type": "image",
+		 *       "format": "url",
+		 *       "value": "https://example.com/scanned-page.png"
+		 *     }
+		 *   }
+		 * ]
+		 * 
+		 * 
+ *

+ * API name: {@code input} + *

+ * Adds one or more values to input. + */ + public final Builder input(DocumentExtractionContentObject value, DocumentExtractionContentObject... values) { + this.input = _listAdd(this.input, value, values); + return this; + } + + /** + * Required - The documents to extract the content from. Either a + * content object or an array of content objects. + *

+ * content object example: + * + *

+		 * "input": {
+		 *   "content": {
+		 *     "type": "pdf",
+		 *     "format": "base64",
+		 *     "value": "data:application/pdf;base64,..."
+		 *   }
+		 * }
+		 * 
+		 * 
+ *

+ * content object array example: + * + *

+		 * "input": [
+		 *   {
+		 *     "content": {
+		 *       "type": "pdf",
+		 *       "format": "base64",
+		 *       "value": "data:application/pdf;base64,..."
+		 *     }
+		 *   },
+		 *   {
+		 *     "content": {
+		 *       "type": "image",
+		 *       "format": "url",
+		 *       "value": "https://example.com/scanned-page.png"
+		 *     }
+		 *   }
+		 * ]
+		 * 
+		 * 
+ *

+ * API name: {@code input} + *

+ * Adds a value to input using a builder lambda. + */ + public final Builder input( + Function> fn) { + return input(fn.apply(new DocumentExtractionContentObject.Builder()).build()); + } + + /** + * Task settings for the individual inference request. These settings are + * specific to the task type you specified and override the task settings + * specified when initializing the service. + *

+ * API name: {@code task_settings} + */ + public final Builder taskSettings(@Nullable DocumentExtractionTaskSettings value) { + this.taskSettings = value; + return this; + } + + /** + * Task settings for the individual inference request. These settings are + * specific to the task type you specified and override the task settings + * specified when initializing the service. + *

+ * API name: {@code task_settings} + */ + public final Builder taskSettings( + Function> fn) { + return this.taskSettings(fn.apply(new DocumentExtractionTaskSettings.Builder()).build()); + } + + /** + * The amount of time to wait for the inference request to complete. + *

+ * API name: {@code timeout} + */ + public final Builder timeout(@Nullable Time value) { + this.timeout = value; + return this; + } + + /** + * The amount of time to wait for the inference request to complete. + *

+ * API name: {@code timeout} + */ + public final Builder timeout(Function> fn) { + return this.timeout(fn.apply(new Time.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DocumentExtractionRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DocumentExtractionRequest build() { + _checkSingleUse(); + + return new DocumentExtractionRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DocumentExtractionRequest} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DocumentExtractionRequest::setupDocumentExtractionRequestDeserializer); + + protected static void setupDocumentExtractionRequestDeserializer( + ObjectDeserializer op) { + + op.add(Builder::input, JsonpDeserializer.arrayDeserializer(DocumentExtractionContentObject._DESERIALIZER), + "input"); + op.add(Builder::taskSettings, DocumentExtractionTaskSettings._DESERIALIZER, "task_settings"); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code inference.document_extraction}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/inference.document_extraction", + + // Request method + request -> { + return "POST"; + + }, + + // Request path + request -> { + final int _inferenceId = 1 << 0; + + int propsSet = 0; + + propsSet |= _inferenceId; + + if (propsSet == (_inferenceId)) { + StringBuilder buf = new StringBuilder(); + buf.append("/_inference"); + buf.append("/document_extraction"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.inferenceId, buf); + return buf.toString(); + } + throw SimpleEndpoint.noPathTemplateFound("path"); + + }, + + // Path parameters + request -> { + Map params = new HashMap<>(); + final int _inferenceId = 1 << 0; + + int propsSet = 0; + + propsSet |= _inferenceId; + + if (propsSet == (_inferenceId)) { + params.put("inferenceId", request.inferenceId); + } + return params; + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.timeout != null) { + params.put("timeout", request.timeout._toJsonString()); + } + return params; + + }, SimpleEndpoint.emptyMap(), true, DocumentExtractionResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionResponse.java new file mode 100644 index 0000000000..352b70719d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionResponse.java @@ -0,0 +1,108 @@ +/* + * 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.inference; + +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.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: inference.document_extraction.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DocumentExtractionResponse extends DocumentExtractionInferenceResult { + // --------------------------------------------------------------------------------------------- + + private DocumentExtractionResponse(Builder builder) { + super(builder); + + } + + public static DocumentExtractionResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DocumentExtractionResponse}. + */ + + public static class Builder extends DocumentExtractionInferenceResult.AbstractBuilder + implements + ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DocumentExtractionResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DocumentExtractionResponse build() { + _checkSingleUse(); + + return new DocumentExtractionResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DocumentExtractionResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DocumentExtractionResponse::setupDocumentExtractionResponseDeserializer); + + protected static void setupDocumentExtractionResponseDeserializer( + ObjectDeserializer op) { + DocumentExtractionInferenceResult.setupDocumentExtractionInferenceResultDeserializer(op); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionResult.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionResult.java new file mode 100644 index 0000000000..22bfec4fc8 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/DocumentExtractionResult.java @@ -0,0 +1,264 @@ +/* + * 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.inference; + +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.JsonpUtils; +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.String; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: inference._types.DocumentExtractionResult + +/** + * The document extraction result object representing the content extracted from + * a single document. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DocumentExtractionResult implements JsonpSerializable { + private final String content; + + private final String format; + + private final Map metadata; + + // --------------------------------------------------------------------------------------------- + + private DocumentExtractionResult(Builder builder) { + + this.content = ApiTypeHelper.requireNonNull(builder.content, this, "content"); + this.format = ApiTypeHelper.requireNonNull(builder.format, this, "format"); + this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); + + } + + public static DocumentExtractionResult of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The content extracted from the document. + *

+ * API name: {@code content} + */ + public final String content() { + return this.content; + } + + /** + * Required - The format of the extracted content, for example + * markdown. + *

+ * API name: {@code format} + */ + public final String format() { + return this.format; + } + + /** + * Additional information about the document, such as its title. The available + * fields depend on the service and model. + *

+ * API name: {@code metadata} + */ + public final Map metadata() { + return this.metadata; + } + + /** + * 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("content"); + generator.write(this.content); + + generator.writeKey("format"); + generator.write(this.format); + + if (ApiTypeHelper.isDefined(this.metadata)) { + generator.writeKey("metadata"); + generator.writeStartObject(); + for (Map.Entry item0 : this.metadata.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DocumentExtractionResult}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String content; + + private String format; + + @Nullable + private Map metadata; + + public Builder() { + } + private Builder(DocumentExtractionResult instance) { + this.content = instance.content; + this.format = instance.format; + this.metadata = instance.metadata; + + } + /** + * Required - The content extracted from the document. + *

+ * API name: {@code content} + */ + public final Builder content(String value) { + this.content = value; + return this; + } + + /** + * Required - The format of the extracted content, for example + * markdown. + *

+ * API name: {@code format} + */ + public final Builder format(String value) { + this.format = value; + return this; + } + + /** + * Additional information about the document, such as its title. The available + * fields depend on the service and model. + *

+ * API name: {@code metadata} + *

+ * Adds all entries of map to metadata. + */ + public final Builder metadata(Map map) { + this.metadata = _mapPutAll(this.metadata, map); + return this; + } + + /** + * Additional information about the document, such as its title. The available + * fields depend on the service and model. + *

+ * API name: {@code metadata} + *

+ * Adds an entry to metadata. + */ + public final Builder metadata(String key, JsonData value) { + this.metadata = _mapPut(this.metadata, key, value); + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DocumentExtractionResult}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DocumentExtractionResult build() { + _checkSingleUse(); + + return new DocumentExtractionResult(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DocumentExtractionResult} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DocumentExtractionResult::setupDocumentExtractionResultDeserializer); + + protected static void setupDocumentExtractionResultDeserializer( + ObjectDeserializer op) { + + op.add(Builder::content, JsonpDeserializer.stringDeserializer(), "content"); + op.add(Builder::format, JsonpDeserializer.stringDeserializer(), "format"); + op.add(Builder::metadata, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "metadata"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceAsyncClient.java index 8d3370d296..7a213f58c0 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceAsyncClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceAsyncClient.java @@ -190,6 +190,61 @@ public final CompletableFuture completion( return completion(fn.apply(new CompletionRequest.Builder()).build()); } + // ----- Endpoint: inference.decision + + /** + * Perform decision inference on the service. + *

+ * Answer a set of named questions about an input, such as whether a customer is + * complaining, which team should handle a request, or how angry a customer is. + * The questions are defined in the task settings of the inference endpoint, and + * can be replaced for a single request through task_settings. + *

+ *

+ * info Only the elastic service currently supports the + * decision task. + *

+ *
+ * + * @see Documentation + * on elastic.co + */ + + public CompletableFuture decision(DecisionRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) DecisionRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Perform decision inference on the service. + *

+ * Answer a set of named questions about an input, such as whether a customer is + * complaining, which team should handle a request, or how angry a customer is. + * The questions are defined in the task settings of the inference endpoint, and + * can be replaced for a single request through task_settings. + *

+ *

+ * info Only the elastic service currently supports the + * decision task. + *

+ *
+ * + * @param fn + * a function that initializes a builder to create the + * {@link DecisionRequest} + * @see Documentation + * on elastic.co + */ + + public final CompletableFuture decision( + Function> fn) { + return decision(fn.apply(new DecisionRequest.Builder()).build()); + } + // ----- Endpoint: inference.delete /** @@ -243,6 +298,45 @@ public CompletableFuture deleteRegionPolicy() { DeleteRegionPolicyRequest._ENDPOINT, this.transportOptions); } + // ----- Endpoint: inference.document_extraction + + /** + * Perform document extraction inference on the service. + *

+ * Extract the content of documents, such as PDFs or images of documents, into a + * textual format. + * + * @see Documentation + * on elastic.co + */ + + public CompletableFuture documentExtraction(DocumentExtractionRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) DocumentExtractionRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Perform document extraction inference on the service. + *

+ * Extract the content of documents, such as PDFs or images of documents, into a + * textual format. + * + * @param fn + * a function that initializes a builder to create the + * {@link DocumentExtractionRequest} + * @see Documentation + * on elastic.co + */ + + public final CompletableFuture documentExtraction( + Function> fn) { + return documentExtraction(fn.apply(new DocumentExtractionRequest.Builder()).build()); + } + // ----- Endpoint: inference.embedding /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceClient.java index 8bc4356381..35e730f539 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceClient.java @@ -190,6 +190,61 @@ public final CompletionResponse completion(Function + * Answer a set of named questions about an input, such as whether a customer is + * complaining, which team should handle a request, or how angry a customer is. + * The questions are defined in the task settings of the inference endpoint, and + * can be replaced for a single request through task_settings. + *

+ *

+ * info Only the elastic service currently supports the + * decision task. + *

+ *
+ * + * @see Documentation + * on elastic.co + */ + + public DecisionResponse decision(DecisionRequest request) throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) DecisionRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Perform decision inference on the service. + *

+ * Answer a set of named questions about an input, such as whether a customer is + * complaining, which team should handle a request, or how angry a customer is. + * The questions are defined in the task settings of the inference endpoint, and + * can be replaced for a single request through task_settings. + *

+ *

+ * info Only the elastic service currently supports the + * decision task. + *

+ *
+ * + * @param fn + * a function that initializes a builder to create the + * {@link DecisionRequest} + * @see Documentation + * on elastic.co + */ + + public final DecisionResponse decision(Function> fn) + throws IOException, ElasticsearchException { + return decision(fn.apply(new DecisionRequest.Builder()).build()); + } + // ----- Endpoint: inference.delete /** @@ -244,6 +299,47 @@ public DeleteRegionPolicyResponse deleteRegionPolicy() throws IOException, Elast this.transportOptions); } + // ----- Endpoint: inference.document_extraction + + /** + * Perform document extraction inference on the service. + *

+ * Extract the content of documents, such as PDFs or images of documents, into a + * textual format. + * + * @see Documentation + * on elastic.co + */ + + public DocumentExtractionResponse documentExtraction(DocumentExtractionRequest request) + throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) DocumentExtractionRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Perform document extraction inference on the service. + *

+ * Extract the content of documents, such as PDFs or images of documents, into a + * textual format. + * + * @param fn + * a function that initializes a builder to create the + * {@link DocumentExtractionRequest} + * @see Documentation + * on elastic.co + */ + + public final DocumentExtractionResponse documentExtraction( + Function> fn) + throws IOException, ElasticsearchException { + return documentExtraction(fn.apply(new DocumentExtractionRequest.Builder()).build()); + } + // ----- Endpoint: inference.embedding /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/EmbeddingContentFormat.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/EmbeddingContentFormat.java index f2e3e1a41d..4efc095908 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/EmbeddingContentFormat.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/EmbeddingContentFormat.java @@ -50,6 +50,8 @@ public enum EmbeddingContentFormat implements JsonEnum { Base64("base64"), + Url("url"), + ; private final String jsonValue; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/EmbeddingContentObjectItem.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/EmbeddingContentObjectItem.java index 05823014eb..d2c1cff336 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/EmbeddingContentObjectItem.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/EmbeddingContentObjectItem.java @@ -95,9 +95,11 @@ public final EmbeddingContentType type() { /** * The format of the input. For the text type this must be - * text. For all other types, this must be base64. If - * not specified, this will default to text for the - * text type and base64 for all other types. + * text. For all other types, this must be base64 or + * url. If not specified, this will default to text + * for the text type and base64 for all other types. + * The url format is available in Elasticsearch 9.6.0 and later. + * Not all services and models support all formats. *

* API name: {@code format} */ @@ -107,8 +109,11 @@ public final EmbeddingContentFormat format() { } /** - * Required - The value of the input to embed. For images, this must be a - * base64-encoded data URI, i.e. "data:content/type;base64,..." + * Required - The value of the input to embed. For the base64 + * format, this must be a base64-encoded data URI, i.e. + * "data:content/type;base64,...". For the url format, + * this must be a URL that points to the content, i.e. "https://example.com/image.jpg". *

* API name: {@code value} */ @@ -181,9 +186,11 @@ public final Builder type(EmbeddingContentType value) { /** * The format of the input. For the text type this must be - * text. For all other types, this must be base64. If - * not specified, this will default to text for the - * text type and base64 for all other types. + * text. For all other types, this must be base64 or + * url. If not specified, this will default to text + * for the text type and base64 for all other types. + * The url format is available in Elasticsearch 9.6.0 and later. + * Not all services and models support all formats. *

* API name: {@code format} */ @@ -193,8 +200,11 @@ public final Builder format(@Nullable EmbeddingContentFormat value) { } /** - * Required - The value of the input to embed. For images, this must be a - * base64-encoded data URI, i.e. "data:content/type;base64,..." + * Required - The value of the input to embed. For the base64 + * format, this must be a base64-encoded data URI, i.e. + * "data:content/type;base64,...". For the url format, + * this must be a URL that points to the content, i.e. "https://example.com/image.jpg". *

* API name: {@code value} */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PredicateDecisionAnswer.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PredicateDecisionAnswer.java new file mode 100644 index 0000000000..cb780c7060 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PredicateDecisionAnswer.java @@ -0,0 +1,184 @@ +/* + * 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.inference; + +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.JsonpUtils; +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.Double; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: inference._types.PredicateDecisionAnswer + +/** + * The answer to a predicate question. + * + * @see API + * specification + */ +@JsonpDeserializable +public class PredicateDecisionAnswer implements DecisionAnswerVariant, JsonpSerializable { + private final double probability; + + // --------------------------------------------------------------------------------------------- + + private PredicateDecisionAnswer(Builder builder) { + + this.probability = ApiTypeHelper.requireNonNull(builder.probability, this, "probability", 0); + + } + + public static PredicateDecisionAnswer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * DecisionAnswer variant kind. + */ + @Override + public DecisionAnswer.Kind _decisionAnswerKind() { + return DecisionAnswer.Kind.Predicate; + } + + /** + * Required - The probability that the statement in the question is true. + *

+ * API name: {@code probability} + */ + public final double probability() { + return this.probability; + } + + /** + * 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.write("type", "predicate"); + + generator.writeKey("probability"); + generator.write(this.probability); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link PredicateDecisionAnswer}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Double probability; + + public Builder() { + } + private Builder(PredicateDecisionAnswer instance) { + this.probability = instance.probability; + + } + /** + * Required - The probability that the statement in the question is true. + *

+ * API name: {@code probability} + */ + public final Builder probability(double value) { + this.probability = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link PredicateDecisionAnswer}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public PredicateDecisionAnswer build() { + _checkSingleUse(); + + return new PredicateDecisionAnswer(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link PredicateDecisionAnswer} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, PredicateDecisionAnswer::setupPredicateDecisionAnswerDeserializer); + + protected static void setupPredicateDecisionAnswerDeserializer( + ObjectDeserializer op) { + + op.add(Builder::probability, JsonpDeserializer.doubleDeserializer(), "probability"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RequestChatCompletion.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RequestChatCompletion.java index ad49c957a3..20a7b32016 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RequestChatCompletion.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RequestChatCompletion.java @@ -74,6 +74,12 @@ public class RequestChatCompletion implements JsonpSerializable { @Nullable private final Reasoning reasoning; + @Nullable + private final CacheControl cacheControl; + + @Nullable + private final String sessionId; + private final List stop; @Nullable @@ -95,6 +101,8 @@ private RequestChatCompletion(Builder builder) { this.model = builder.model; this.maxCompletionTokens = builder.maxCompletionTokens; this.reasoning = builder.reasoning; + this.cacheControl = builder.cacheControl; + this.sessionId = builder.sessionId; this.stop = ApiTypeHelper.unmodifiable(builder.stop); this.temperature = builder.temperature; this.toolChoice = builder.toolChoice; @@ -196,6 +204,40 @@ public final Reasoning reasoning() { return this.reasoning; } + /** + * The prompt caching configuration for the completion request. Example: + * + *

+	 * {
+	 *   "cache_control": {
+	 *     "type": "ephemeral",
+	 *     "ttl": "1h"
+	 *   }
+	 * }
+	 * 
+	 * 
+ *

+ * Unknown fields in the object and invalid ttl values return an + * error. Currently supported only for elastic provider. + *

+ * API name: {@code cache_control} + */ + @Nullable + public final CacheControl cacheControl() { + return this.cacheControl; + } + + /** + * An identifier that groups related completion requests into a session. + * Currently supported only for elastic provider. + *

+ * API name: {@code session_id} + */ + @Nullable + public final String sessionId() { + return this.sessionId; + } + /** * A sequence of strings to control when the model should stop generating * additional tokens. @@ -323,6 +365,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("reasoning"); this.reasoning.serialize(generator, mapper); + } + if (this.cacheControl != null) { + generator.writeKey("cache_control"); + this.cacheControl.serialize(generator, mapper); + + } + if (this.sessionId != null) { + generator.writeKey("session_id"); + generator.write(this.sessionId); + } if (ApiTypeHelper.isDefined(this.stop)) { generator.writeKey("stop"); @@ -387,6 +439,12 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Reasoning reasoning; + @Nullable + private CacheControl cacheControl; + + @Nullable + private String sessionId; + @Nullable private List stop; @@ -409,6 +467,8 @@ private Builder(RequestChatCompletion instance) { this.model = instance.model; this.maxCompletionTokens = instance.maxCompletionTokens; this.reasoning = instance.reasoning; + this.cacheControl = instance.cacheControl; + this.sessionId = instance.sessionId; this.stop = instance.stop; this.temperature = instance.temperature; this.toolChoice = instance.toolChoice; @@ -593,6 +653,62 @@ public final Builder reasoning(Function + * { + * "cache_control": { + * "type": "ephemeral", + * "ttl": "1h" + * } + * } + * + * + *

+ * Unknown fields in the object and invalid ttl values return an + * error. Currently supported only for elastic provider. + *

+ * API name: {@code cache_control} + */ + public final Builder cacheControl(@Nullable CacheControl value) { + this.cacheControl = value; + return this; + } + + /** + * The prompt caching configuration for the completion request. Example: + * + *

+		 * {
+		 *   "cache_control": {
+		 *     "type": "ephemeral",
+		 *     "ttl": "1h"
+		 *   }
+		 * }
+		 * 
+		 * 
+ *

+ * Unknown fields in the object and invalid ttl values return an + * error. Currently supported only for elastic provider. + *

+ * API name: {@code cache_control} + */ + public final Builder cacheControl(Function> fn) { + return this.cacheControl(fn.apply(new CacheControl.Builder()).build()); + } + + /** + * An identifier that groups related completion requests into a session. + * Currently supported only for elastic provider. + *

+ * API name: {@code session_id} + */ + public final Builder sessionId(@Nullable String value) { + this.sessionId = value; + return this; + } + /** * A sequence of strings to control when the model should stop generating * additional tokens. @@ -843,6 +959,8 @@ protected static void setupRequestChatCompletionDeserializer(ObjectDeserializer< op.add(Builder::model, JsonpDeserializer.stringDeserializer(), "model"); op.add(Builder::maxCompletionTokens, JsonpDeserializer.longDeserializer(), "max_completion_tokens"); op.add(Builder::reasoning, Reasoning._DESERIALIZER, "reasoning"); + op.add(Builder::cacheControl, CacheControl._DESERIALIZER, "cache_control"); + op.add(Builder::sessionId, JsonpDeserializer.stringDeserializer(), "session_id"); op.add(Builder::stop, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stop"); op.add(Builder::temperature, JsonpDeserializer.floatDeserializer(), "temperature"); op.add(Builder::toolChoice, CompletionToolType._DESERIALIZER, "tool_choice"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RequestEmbedding.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RequestEmbedding.java index 9c5676ebc8..7201084e6e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RequestEmbedding.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RequestEmbedding.java @@ -141,6 +141,20 @@ public static RequestEmbedding of(Function * *

+ * content object using the url format example + * (available in Elasticsearch 9.6.0 and later): + * + *

+	 * "input": {
+	 *     "content": {
+	 *       "type": "image",
+	 *       "format": "url",
+	 *       "value": "https://example.com/image.jpg"
+	 *     }
+	 *   }
+	 * 
+	 * 
+ *

* Multiple items in one content object example (available in * Elasticsearch 9.5.0 and later): * @@ -321,6 +335,20 @@ private Builder(RequestEmbedding instance) { * * *

+ * content object using the url format example + * (available in Elasticsearch 9.6.0 and later): + * + *

+		 * "input": {
+		 *     "content": {
+		 *       "type": "image",
+		 *       "format": "url",
+		 *       "value": "https://example.com/image.jpg"
+		 *     }
+		 *   }
+		 * 
+		 * 
+ *

* Multiple items in one content object example (available in * Elasticsearch 9.5.0 and later): * @@ -408,6 +436,20 @@ public final Builder input(EmbeddingInput value) { * * *

+ * content object using the url format example + * (available in Elasticsearch 9.6.0 and later): + * + *

+		 * "input": {
+		 *     "content": {
+		 *       "type": "image",
+		 *       "format": "url",
+		 *       "value": "https://example.com/image.jpg"
+		 *     }
+		 *   }
+		 * 
+		 * 
+ *

* Multiple items in one content object example (available in * Elasticsearch 9.5.0 and later): * diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RerankRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RerankRequest.java index 05ce0a5a5b..56a616e9c6 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RerankRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/RerankRequest.java @@ -170,6 +170,20 @@ public final String inferenceId() { * * *

+ * object array example using the url format (available in + * Elasticsearch 9.6.0 and later): + * + *

+	 * "input": [
+	 *   {
+	 *     "type": "image",
+	 *     "format": "url",
+	 *     "value": "https://example.com/image.jpg"
+	 *   }
+	 * ]
+	 * 
+	 * 
+ *

* API name: {@code input} */ public final RerankInput input() { @@ -205,6 +219,18 @@ public final RerankInput input() { * * *

+ * object example using the url format (available in Elasticsearch + * 9.6.0 and later): + * + *

+	 * "query": {
+	 *   "type": "image",
+	 *   "format": "url",
+	 *   "value": "https://example.com/image.jpg"
+	 * }
+	 * 
+	 * 
+ *

* API name: {@code query} */ public final RerankQuery query() { @@ -390,6 +416,20 @@ public final Builder inferenceId(String value) { * * *

+ * object array example using the url format (available in + * Elasticsearch 9.6.0 and later): + * + *

+		 * "input": [
+		 *   {
+		 *     "type": "image",
+		 *     "format": "url",
+		 *     "value": "https://example.com/image.jpg"
+		 *   }
+		 * ]
+		 * 
+		 * 
+ *

* API name: {@code input} */ public final Builder input(RerankInput value) { @@ -452,6 +492,20 @@ public final Builder input(RerankInput value) { * * *

+ * object array example using the url format (available in + * Elasticsearch 9.6.0 and later): + * + *

+		 * "input": [
+		 *   {
+		 *     "type": "image",
+		 *     "format": "url",
+		 *     "value": "https://example.com/image.jpg"
+		 *   }
+		 * ]
+		 * 
+		 * 
+ *

* API name: {@code input} */ public final Builder input(Function> fn) { @@ -487,6 +541,18 @@ public final Builder input(Function * *

+ * object example using the url format (available in Elasticsearch + * 9.6.0 and later): + * + *

+		 * "query": {
+		 *   "type": "image",
+		 *   "format": "url",
+		 *   "value": "https://example.com/image.jpg"
+		 * }
+		 * 
+		 * 
+ *

* API name: {@code query} */ public final Builder query(RerankQuery value) { @@ -523,6 +589,18 @@ public final Builder query(RerankQuery value) { * * *

+ * object example using the url format (available in Elasticsearch + * 9.6.0 and later): + * + *

+		 * "query": {
+		 *   "type": "image",
+		 *   "format": "url",
+		 *   "value": "https://example.com/image.jpg"
+		 * }
+		 * 
+		 * 
+ *

* API name: {@code query} */ public final Builder query(Function> fn) { diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ScoreDecisionAnswer.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ScoreDecisionAnswer.java new file mode 100644 index 0000000000..be8adec894 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ScoreDecisionAnswer.java @@ -0,0 +1,283 @@ +/* + * 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.inference; + +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.JsonpUtils; +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.Double; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: inference._types.ScoreDecisionAnswer + +/** + * The answer to a score question. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ScoreDecisionAnswer implements DecisionAnswerVariant, JsonpSerializable { + private final double score; + + private final List probabilities; + + private final double confidence; + + // --------------------------------------------------------------------------------------------- + + private ScoreDecisionAnswer(Builder builder) { + + this.score = ApiTypeHelper.requireNonNull(builder.score, this, "score", 0); + this.probabilities = ApiTypeHelper.unmodifiableRequired(builder.probabilities, this, "probabilities"); + this.confidence = ApiTypeHelper.requireNonNull(builder.confidence, this, "confidence", 0); + + } + + public static ScoreDecisionAnswer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * DecisionAnswer variant kind. + */ + @Override + public DecisionAnswer.Kind _decisionAnswerKind() { + return DecisionAnswer.Kind.Score; + } + + /** + * Required - The probability-weighted position on the scale, from + * 0 for the lowest level. + *

+ * API name: {@code score} + */ + public final double score() { + return this.score; + } + + /** + * Required - The probability of each level, ordered from the lowest to the + * highest level. + *

+ * API name: {@code probabilities} + */ + public final List probabilities() { + return this.probabilities; + } + + /** + * Required - The confidence in the score. + *

+ * API name: {@code confidence} + */ + public final double confidence() { + return this.confidence; + } + + /** + * 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.write("type", "score"); + + generator.writeKey("score"); + generator.write(this.score); + + if (ApiTypeHelper.isDefined(this.probabilities)) { + generator.writeKey("probabilities"); + generator.writeStartArray(); + for (ScoreDecisionProbability item0 : this.probabilities) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("confidence"); + generator.write(this.confidence); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ScoreDecisionAnswer}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Double score; + + private List probabilities; + + private Double confidence; + + public Builder() { + } + private Builder(ScoreDecisionAnswer instance) { + this.score = instance.score; + this.probabilities = instance.probabilities; + this.confidence = instance.confidence; + + } + /** + * Required - The probability-weighted position on the scale, from + * 0 for the lowest level. + *

+ * API name: {@code score} + */ + public final Builder score(double value) { + this.score = value; + return this; + } + + /** + * Required - The probability of each level, ordered from the lowest to the + * highest level. + *

+ * API name: {@code probabilities} + *

+ * Adds all elements of list to probabilities. + */ + public final Builder probabilities(List list) { + this.probabilities = _listAddAll(this.probabilities, list); + return this; + } + + /** + * Required - The probability of each level, ordered from the lowest to the + * highest level. + *

+ * API name: {@code probabilities} + *

+ * Adds one or more values to probabilities. + */ + public final Builder probabilities(ScoreDecisionProbability value, ScoreDecisionProbability... values) { + this.probabilities = _listAdd(this.probabilities, value, values); + return this; + } + + /** + * Required - The probability of each level, ordered from the lowest to the + * highest level. + *

+ * API name: {@code probabilities} + *

+ * Adds a value to probabilities using a builder lambda. + */ + public final Builder probabilities( + Function> fn) { + return probabilities(fn.apply(new ScoreDecisionProbability.Builder()).build()); + } + + /** + * Required - The confidence in the score. + *

+ * API name: {@code confidence} + */ + public final Builder confidence(double value) { + this.confidence = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ScoreDecisionAnswer}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ScoreDecisionAnswer build() { + _checkSingleUse(); + + return new ScoreDecisionAnswer(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ScoreDecisionAnswer} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ScoreDecisionAnswer::setupScoreDecisionAnswerDeserializer); + + protected static void setupScoreDecisionAnswerDeserializer(ObjectDeserializer op) { + + op.add(Builder::score, JsonpDeserializer.doubleDeserializer(), "score"); + op.add(Builder::probabilities, JsonpDeserializer.arrayDeserializer(ScoreDecisionProbability._DESERIALIZER), + "probabilities"); + op.add(Builder::confidence, JsonpDeserializer.doubleDeserializer(), "confidence"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ScoreDecisionProbability.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ScoreDecisionProbability.java new file mode 100644 index 0000000000..8cd103ca31 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ScoreDecisionProbability.java @@ -0,0 +1,235 @@ +/* + * 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.inference; + +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.JsonpUtils; +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.Double; +import java.lang.Integer; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +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: inference._types.ScoreDecisionProbability + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ScoreDecisionProbability implements JsonpSerializable { + private final int value; + + private final String label; + + private final double probability; + + // --------------------------------------------------------------------------------------------- + + private ScoreDecisionProbability(Builder builder) { + + this.value = ApiTypeHelper.requireNonNull(builder.value, this, "value", 0); + this.label = ApiTypeHelper.requireNonNull(builder.label, this, "label"); + this.probability = ApiTypeHelper.requireNonNull(builder.probability, this, "probability", 0); + + } + + public static ScoreDecisionProbability of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The zero-based position of the level, which is also its position + * in the array. + *

+ * API name: {@code value} + */ + public final int value() { + return this.value; + } + + /** + * Required - The label of the level. + *

+ * API name: {@code label} + */ + public final String label() { + return this.label; + } + + /** + * Required - The probability of the level. + *

+ * API name: {@code probability} + */ + public final double probability() { + return this.probability; + } + + /** + * 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("value"); + generator.write(this.value); + + generator.writeKey("label"); + generator.write(this.label); + + generator.writeKey("probability"); + generator.write(this.probability); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ScoreDecisionProbability}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Integer value; + + private String label; + + private Double probability; + + public Builder() { + } + private Builder(ScoreDecisionProbability instance) { + this.value = instance.value; + this.label = instance.label; + this.probability = instance.probability; + + } + /** + * Required - The zero-based position of the level, which is also its position + * in the array. + *

+ * API name: {@code value} + */ + public final Builder value(int value) { + this.value = value; + return this; + } + + /** + * Required - The label of the level. + *

+ * API name: {@code label} + */ + public final Builder label(String value) { + this.label = value; + return this; + } + + /** + * Required - The probability of the level. + *

+ * API name: {@code probability} + */ + public final Builder probability(double value) { + this.probability = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ScoreDecisionProbability}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ScoreDecisionProbability build() { + _checkSingleUse(); + + return new ScoreDecisionProbability(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ScoreDecisionProbability} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ScoreDecisionProbability::setupScoreDecisionProbabilityDeserializer); + + protected static void setupScoreDecisionProbabilityDeserializer( + ObjectDeserializer op) { + + op.add(Builder::value, JsonpDeserializer.integerDeserializer(), "value"); + op.add(Builder::label, JsonpDeserializer.stringDeserializer(), "label"); + op.add(Builder::probability, JsonpDeserializer.doubleDeserializer(), "probability"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/TaskType.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/TaskType.java index e379afe0b0..6a675d595c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/TaskType.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/TaskType.java @@ -57,6 +57,10 @@ public enum TaskType implements JsonEnum { Embedding("embedding"), + DocumentExtraction("document_extraction"), + + Decision("decision"), + ; private final String jsonValue; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/ChoiceDecisionQuestion.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/ChoiceDecisionQuestion.java new file mode 100644 index 0000000000..bd60527c17 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/ChoiceDecisionQuestion.java @@ -0,0 +1,197 @@ +/* + * 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.inference.decision; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +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 jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: inference.decision.ChoiceDecisionQuestion + +/** + * A question answered with one option out of a fixed set of choices. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ChoiceDecisionQuestion extends DecisionQuestionBase implements DecisionQuestionVariant { + private final Map choices; + + // --------------------------------------------------------------------------------------------- + + private ChoiceDecisionQuestion(Builder builder) { + super(builder); + + this.choices = ApiTypeHelper.unmodifiableRequired(builder.choices, this, "choices"); + + } + + public static ChoiceDecisionQuestion of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * DecisionQuestion variant kind. + */ + @Override + public DecisionQuestion.Kind _decisionQuestionKind() { + return DecisionQuestion.Kind.Choice; + } + + /** + * Required - The options to choose from, each mapped to an optional + * description. At least two choices are required. + *

+ * API name: {@code choices} + */ + public final Map choices() { + return this.choices; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "choice"); + super.serializeInternal(generator, mapper); + if (ApiTypeHelper.isDefined(this.choices)) { + generator.writeKey("choices"); + generator.writeStartObject(); + for (Map.Entry item0 : this.choices.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChoiceDecisionQuestion}. + */ + + public static class Builder extends DecisionQuestionBase.AbstractBuilder + implements + ObjectBuilder { + private Map choices; + + public Builder() { + } + private Builder(ChoiceDecisionQuestion instance) { + this.choices = instance.choices; + + } + /** + * Required - The options to choose from, each mapped to an optional + * description. At least two choices are required. + *

+ * API name: {@code choices} + *

+ * Adds all entries of map to choices. + */ + public final Builder choices(Map map) { + this.choices = _mapPutAll(this.choices, map); + return this; + } + + /** + * Required - The options to choose from, each mapped to an optional + * description. At least two choices are required. + *

+ * API name: {@code choices} + *

+ * Adds an entry to choices. + */ + public final Builder choices(String key, String value) { + this.choices = _mapPut(this.choices, key, value); + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ChoiceDecisionQuestion}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChoiceDecisionQuestion build() { + _checkSingleUse(); + + return new ChoiceDecisionQuestion(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChoiceDecisionQuestion} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ChoiceDecisionQuestion::setupChoiceDecisionQuestionDeserializer); + + protected static void setupChoiceDecisionQuestionDeserializer( + ObjectDeserializer op) { + DecisionQuestionBase.setupDecisionQuestionBaseDeserializer(op); + op.add(Builder::choices, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), + "choices"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionInput.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionInput.java new file mode 100644 index 0000000000..e4db94798c --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionInput.java @@ -0,0 +1,196 @@ +/* + * 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.inference.decision; + +import co.elastic.clients.elasticsearch.inference.EmbeddingContentObjectItem; +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.JsonpUtils; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.json.UnionDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.ObjectBuilderBase; +import co.elastic.clients.util.TaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; +import jakarta.json.stream.JsonGenerator; +import java.lang.Object; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +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: inference.decision.DecisionInput + +/** + * The input for the decision task. Either a string, or an object. + * The object form additionally allows specifying images. The + * decision task currently only supports the text and + * image types. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DecisionInput implements TaggedUnion, JsonpSerializable { + + public enum Kind { + Object, String + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + private DecisionInput(Kind kind, Object value) { + this._kind = kind; + this._value = value; + } + + private DecisionInput(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static DecisionInput of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code object}? + */ + public boolean isObject() { + return _kind == Kind.Object; + } + + /** + * Get the {@code object} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code object} kind. + */ + public EmbeddingContentObjectItem object() { + return TaggedUnionUtils.get(this, Kind.Object); + } + + /** + * Is this variant instance of kind {@code string}? + */ + public boolean isString() { + return _kind == Kind.String; + } + + /** + * Get the {@code string} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code string} kind. + */ + public String string() { + return TaggedUnionUtils.get(this, Kind.String); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } else { + switch (_kind) { + case String : + generator.write(((String) this._value)); + + break; + } + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder object(EmbeddingContentObjectItem v) { + this._kind = Kind.Object; + this._value = v; + return this; + } + + public ObjectBuilder object( + Function> fn) { + return this.object(fn.apply(new EmbeddingContentObjectItem.Builder()).build()); + } + + public ObjectBuilder string(String v) { + this._kind = Kind.String; + this._value = v; + return this; + } + + public DecisionInput build() { + _checkSingleUse(); + return new DecisionInput(this); + } + + } + + private static JsonpDeserializer buildDecisionInputDeserializer() { + return new UnionDeserializer.Builder(DecisionInput::new, false) + .addMember(Kind.Object, EmbeddingContentObjectItem._DESERIALIZER) + .addMember(Kind.String, JsonpDeserializer.stringDeserializer()).build(); + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer + .lazy(DecisionInput::buildDecisionInputDeserializer); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionInputBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionInputBuilders.java new file mode 100644 index 0000000000..4948790cea --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionInputBuilders.java @@ -0,0 +1,60 @@ +/* + * 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.inference.decision; + +import co.elastic.clients.elasticsearch.inference.EmbeddingContentObjectItem; +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link DecisionInput} variants. + *

+ * Variants string are not available here as they don't have a + * dedicated class. Use {@link DecisionInput}'s builder for these. + * + */ +public class DecisionInputBuilders { + private DecisionInputBuilders() { + } + + /** + * Creates a builder for the {@link EmbeddingContentObjectItem object} + * {@code DecisionInput} variant. + */ + public static EmbeddingContentObjectItem.Builder object() { + return new EmbeddingContentObjectItem.Builder(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestion.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestion.java new file mode 100644 index 0000000000..afa492e512 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestion.java @@ -0,0 +1,254 @@ +/* + * 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.inference.decision; + +import co.elastic.clients.json.JsonEnum; +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.JsonpUtils; +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.TaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +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: inference.decision.DecisionQuestion + +/** + * A question answered by the decision task. The type of the + * question determines the type of its answer. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DecisionQuestion + implements + TaggedUnion, + JsonpSerializable { + + /** + * {@link DecisionQuestion} variant kinds. + * + * @see API + * specification + */ + + public enum Kind implements JsonEnum { + Choice("choice"), + + Predicate("predicate"), + + Score("score"), + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final DecisionQuestionVariant _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final DecisionQuestionVariant _get() { + return _value; + } + + public DecisionQuestion(DecisionQuestionVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._decisionQuestionKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + + } + + private DecisionQuestion(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static DecisionQuestion of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code choice}? + */ + public boolean isChoice() { + return _kind == Kind.Choice; + } + + /** + * Get the {@code choice} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code choice} kind. + */ + public ChoiceDecisionQuestion choice() { + return TaggedUnionUtils.get(this, Kind.Choice); + } + + /** + * Is this variant instance of kind {@code predicate}? + */ + public boolean isPredicate() { + return _kind == Kind.Predicate; + } + + /** + * Get the {@code predicate} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code predicate} kind. + */ + public PredicateDecisionQuestion predicate() { + return TaggedUnionUtils.get(this, Kind.Predicate); + } + + /** + * Is this variant instance of kind {@code score}? + */ + public boolean isScore() { + return _kind == Kind.Score; + } + + /** + * Get the {@code score} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code score} kind. + */ + public ScoreDecisionQuestion score() { + return TaggedUnionUtils.get(this, Kind.Score); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + + mapper.serialize(_value, generator); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private DecisionQuestionVariant _value; + + @Override + protected Builder self() { + return this; + } + public ObjectBuilder choice(ChoiceDecisionQuestion v) { + this._kind = Kind.Choice; + this._value = v; + return this; + } + + public ObjectBuilder choice( + Function> fn) { + return this.choice(fn.apply(new ChoiceDecisionQuestion.Builder()).build()); + } + + public ObjectBuilder predicate(PredicateDecisionQuestion v) { + this._kind = Kind.Predicate; + this._value = v; + return this; + } + + public ObjectBuilder predicate( + Function> fn) { + return this.predicate(fn.apply(new PredicateDecisionQuestion.Builder()).build()); + } + + public ObjectBuilder score(ScoreDecisionQuestion v) { + this._kind = Kind.Score; + this._value = v; + return this; + } + + public ObjectBuilder score( + Function> fn) { + return this.score(fn.apply(new ScoreDecisionQuestion.Builder()).build()); + } + + public DecisionQuestion build() { + _checkSingleUse(); + return new DecisionQuestion(this); + } + + } + + protected static void setupDecisionQuestionDeserializer(ObjectDeserializer op) { + + op.add(Builder::choice, ChoiceDecisionQuestion._DESERIALIZER, "choice"); + op.add(Builder::predicate, PredicateDecisionQuestion._DESERIALIZER, "predicate"); + op.add(Builder::score, ScoreDecisionQuestion._DESERIALIZER, "score"); + + op.setTypeProperty("type", null); + + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + DecisionQuestion::setupDecisionQuestionDeserializer, Builder::build); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestionBase.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestionBase.java new file mode 100644 index 0000000000..13f8d19dd7 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestionBase.java @@ -0,0 +1,129 @@ +/* + * 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.inference.decision; + +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.JsonpUtils; +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.String; +import java.util.Objects; +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: inference.decision.DecisionQuestionBase + +/** + * + * @see API + * specification + */ + +public abstract class DecisionQuestionBase implements JsonpSerializable { + private final String instructions; + + // --------------------------------------------------------------------------------------------- + + protected DecisionQuestionBase(AbstractBuilder builder) { + + this.instructions = ApiTypeHelper.requireNonNull(builder.instructions, this, "instructions"); + + } + + /** + * Required - A description of what to decide. It must not be empty. + *

+ * API name: {@code instructions} + */ + public final String instructions() { + return this.instructions; + } + + /** + * 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("instructions"); + generator.write(this.instructions); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + private String instructions; + + /** + * Required - A description of what to decide. It must not be empty. + *

+ * API name: {@code instructions} + */ + public final BuilderT instructions(String value) { + this.instructions = value; + return self(); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupDecisionQuestionBaseDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::instructions, JsonpDeserializer.stringDeserializer(), "instructions"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestionBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestionBuilders.java new file mode 100644 index 0000000000..7ffaf8d8a4 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestionBuilders.java @@ -0,0 +1,104 @@ +/* + * 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.inference.decision; + +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link DecisionQuestion} variants. + */ +public class DecisionQuestionBuilders { + private DecisionQuestionBuilders() { + } + + /** + * Creates a builder for the {@link ChoiceDecisionQuestion choice} + * {@code DecisionQuestion} variant. + */ + public static ChoiceDecisionQuestion.Builder choice() { + return new ChoiceDecisionQuestion.Builder(); + } + + /** + * Creates a DecisionQuestion of the {@link ChoiceDecisionQuestion choice} + * {@code DecisionQuestion} variant. + */ + public static DecisionQuestion choice( + Function> fn) { + DecisionQuestion.Builder builder = new DecisionQuestion.Builder(); + builder.choice(fn.apply(new ChoiceDecisionQuestion.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link PredicateDecisionQuestion predicate} + * {@code DecisionQuestion} variant. + */ + public static PredicateDecisionQuestion.Builder predicate() { + return new PredicateDecisionQuestion.Builder(); + } + + /** + * Creates a DecisionQuestion of the {@link PredicateDecisionQuestion predicate} + * {@code DecisionQuestion} variant. + */ + public static DecisionQuestion predicate( + Function> fn) { + DecisionQuestion.Builder builder = new DecisionQuestion.Builder(); + builder.predicate(fn.apply(new PredicateDecisionQuestion.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link ScoreDecisionQuestion score} + * {@code DecisionQuestion} variant. + */ + public static ScoreDecisionQuestion.Builder score() { + return new ScoreDecisionQuestion.Builder(); + } + + /** + * Creates a DecisionQuestion of the {@link ScoreDecisionQuestion score} + * {@code DecisionQuestion} variant. + */ + public static DecisionQuestion score( + Function> fn) { + DecisionQuestion.Builder builder = new DecisionQuestion.Builder(); + builder.score(fn.apply(new ScoreDecisionQuestion.Builder()).build()); + return builder.build(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestionVariant.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestionVariant.java new file mode 100644 index 0000000000..4d14c892d1 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionQuestionVariant.java @@ -0,0 +1,50 @@ +/* + * 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.inference.decision; + +import co.elastic.clients.json.JsonpSerializable; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Base interface for {@link DecisionQuestion} variants. + */ +public interface DecisionQuestionVariant extends JsonpSerializable { + + DecisionQuestion.Kind _decisionQuestionKind(); + + default DecisionQuestion _toDecisionQuestion() { + return new DecisionQuestion(this); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionScoreLevel.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionScoreLevel.java new file mode 100644 index 0000000000..df5ab4c43e --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionScoreLevel.java @@ -0,0 +1,193 @@ +/* + * 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.inference.decision; + +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.JsonpUtils; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.json.UnionDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.ObjectBuilderBase; +import co.elastic.clients.util.TaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; +import jakarta.json.stream.JsonGenerator; +import java.lang.Object; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +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: inference.decision.DecisionScoreLevel + +/** + * A level of a score question: either a plain label, or an object + * with a label and an optional description. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DecisionScoreLevel implements TaggedUnion, JsonpSerializable { + + public enum Kind { + Object, Label + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + private DecisionScoreLevel(Kind kind, Object value) { + this._kind = kind; + this._value = value; + } + + private DecisionScoreLevel(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static DecisionScoreLevel of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code object}? + */ + public boolean isObject() { + return _kind == Kind.Object; + } + + /** + * Get the {@code object} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code object} kind. + */ + public DecisionScoreLevelObject object() { + return TaggedUnionUtils.get(this, Kind.Object); + } + + /** + * Is this variant instance of kind {@code label}? + */ + public boolean isLabel() { + return _kind == Kind.Label; + } + + /** + * Get the {@code label} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code label} kind. + */ + public String label() { + return TaggedUnionUtils.get(this, Kind.Label); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } else { + switch (_kind) { + case Label : + generator.write(((String) this._value)); + + break; + } + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder object(DecisionScoreLevelObject v) { + this._kind = Kind.Object; + this._value = v; + return this; + } + + public ObjectBuilder object( + Function> fn) { + return this.object(fn.apply(new DecisionScoreLevelObject.Builder()).build()); + } + + public ObjectBuilder label(String v) { + this._kind = Kind.Label; + this._value = v; + return this; + } + + public DecisionScoreLevel build() { + _checkSingleUse(); + return new DecisionScoreLevel(this); + } + + } + + private static JsonpDeserializer buildDecisionScoreLevelDeserializer() { + return new UnionDeserializer.Builder(DecisionScoreLevel::new, false) + .addMember(Kind.Object, DecisionScoreLevelObject._DESERIALIZER) + .addMember(Kind.Label, JsonpDeserializer.stringDeserializer()).build(); + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer + .lazy(DecisionScoreLevel::buildDecisionScoreLevelDeserializer); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionScoreLevelBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionScoreLevelBuilders.java new file mode 100644 index 0000000000..ac5886a0ac --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionScoreLevelBuilders.java @@ -0,0 +1,59 @@ +/* + * 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.inference.decision; + +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link DecisionScoreLevel} variants. + *

+ * Variants label are not available here as they don't have a + * dedicated class. Use {@link DecisionScoreLevel}'s builder for these. + * + */ +public class DecisionScoreLevelBuilders { + private DecisionScoreLevelBuilders() { + } + + /** + * Creates a builder for the {@link DecisionScoreLevelObject object} + * {@code DecisionScoreLevel} variant. + */ + public static DecisionScoreLevelObject.Builder object() { + return new DecisionScoreLevelObject.Builder(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionScoreLevelObject.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionScoreLevelObject.java new file mode 100644 index 0000000000..178b25bb3b --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionScoreLevelObject.java @@ -0,0 +1,208 @@ +/* + * 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.inference.decision; + +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: inference.decision.DecisionScoreLevelObject + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DecisionScoreLevelObject implements JsonpSerializable { + private final String label; + + @Nullable + private final String description; + + // --------------------------------------------------------------------------------------------- + + private DecisionScoreLevelObject(Builder builder) { + + this.label = ApiTypeHelper.requireNonNull(builder.label, this, "label"); + this.description = builder.description; + + } + + public static DecisionScoreLevelObject of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The label of the level. + *

+ * API name: {@code label} + */ + public final String label() { + return this.label; + } + + /** + * A description of the level. + *

+ * API name: {@code description} + */ + @Nullable + public final String description() { + return this.description; + } + + /** + * 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("label"); + generator.write(this.label); + + if (this.description != null) { + generator.writeKey("description"); + generator.write(this.description); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DecisionScoreLevelObject}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String label; + + @Nullable + private String description; + + public Builder() { + } + private Builder(DecisionScoreLevelObject instance) { + this.label = instance.label; + this.description = instance.description; + + } + /** + * Required - The label of the level. + *

+ * API name: {@code label} + */ + public final Builder label(String value) { + this.label = value; + return this; + } + + /** + * A description of the level. + *

+ * API name: {@code description} + */ + public final Builder description(@Nullable String value) { + this.description = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DecisionScoreLevelObject}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DecisionScoreLevelObject build() { + _checkSingleUse(); + + return new DecisionScoreLevelObject(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DecisionScoreLevelObject} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DecisionScoreLevelObject::setupDecisionScoreLevelObjectDeserializer); + + protected static void setupDecisionScoreLevelObjectDeserializer( + ObjectDeserializer op) { + + op.add(Builder::label, JsonpDeserializer.stringDeserializer(), "label"); + op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionTaskSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionTaskSettings.java new file mode 100644 index 0000000000..d1cc8e51cb --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/DecisionTaskSettings.java @@ -0,0 +1,219 @@ +/* + * 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.inference.decision; + +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.JsonpUtils; +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.String; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: inference.decision.DecisionTaskSettings + +/** + * The task settings of the decision task. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DecisionTaskSettings implements JsonpSerializable { + private final Map questions; + + // --------------------------------------------------------------------------------------------- + + private DecisionTaskSettings(Builder builder) { + + this.questions = ApiTypeHelper.unmodifiable(builder.questions); + + } + + public static DecisionTaskSettings of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The questions to answer, keyed by question name. The answers in the response + * use the same names. The questions replace the ones of the inference endpoint + * as a whole. At least one question is required. + *

+ * API name: {@code questions} + */ + public final Map questions() { + return this.questions; + } + + /** + * 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.questions)) { + generator.writeKey("questions"); + generator.writeStartObject(); + for (Map.Entry item0 : this.questions.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DecisionTaskSettings}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private Map questions; + + public Builder() { + } + private Builder(DecisionTaskSettings instance) { + this.questions = instance.questions; + + } + /** + * The questions to answer, keyed by question name. The answers in the response + * use the same names. The questions replace the ones of the inference endpoint + * as a whole. At least one question is required. + *

+ * API name: {@code questions} + *

+ * Adds all entries of map to questions. + */ + public final Builder questions(Map map) { + this.questions = _mapPutAll(this.questions, map); + return this; + } + + /** + * The questions to answer, keyed by question name. The answers in the response + * use the same names. The questions replace the ones of the inference endpoint + * as a whole. At least one question is required. + *

+ * API name: {@code questions} + *

+ * Adds an entry to questions. + */ + public final Builder questions(String key, DecisionQuestion value) { + this.questions = _mapPut(this.questions, key, value); + return this; + } + + /** + * The questions to answer, keyed by question name. The answers in the response + * use the same names. The questions replace the ones of the inference endpoint + * as a whole. At least one question is required. + *

+ * API name: {@code questions} + *

+ * Adds an entry to questions using a builder lambda. + */ + public final Builder questions(String key, + Function> fn) { + return questions(key, fn.apply(new DecisionQuestion.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DecisionTaskSettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DecisionTaskSettings build() { + _checkSingleUse(); + + return new DecisionTaskSettings(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DecisionTaskSettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DecisionTaskSettings::setupDecisionTaskSettingsDeserializer); + + protected static void setupDecisionTaskSettingsDeserializer(ObjectDeserializer op) { + + op.add(Builder::questions, JsonpDeserializer.stringMapDeserializer(DecisionQuestion._DESERIALIZER), + "questions"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/PredicateDecisionQuestion.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/PredicateDecisionQuestion.java new file mode 100644 index 0000000000..bcbc8a640b --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/PredicateDecisionQuestion.java @@ -0,0 +1,138 @@ +/* + * 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.inference.decision; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: inference.decision.PredicateDecisionQuestion + +/** + * A question answered with the probability that the statement in + * instructions is true. + * + * @see API + * specification + */ +@JsonpDeserializable +public class PredicateDecisionQuestion extends DecisionQuestionBase implements DecisionQuestionVariant { + // --------------------------------------------------------------------------------------------- + + private PredicateDecisionQuestion(Builder builder) { + super(builder); + + } + + public static PredicateDecisionQuestion of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * DecisionQuestion variant kind. + */ + @Override + public DecisionQuestion.Kind _decisionQuestionKind() { + return DecisionQuestion.Kind.Predicate; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "predicate"); + super.serializeInternal(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link PredicateDecisionQuestion}. + */ + + public static class Builder extends DecisionQuestionBase.AbstractBuilder + implements + ObjectBuilder { + public Builder() { + } + private Builder(PredicateDecisionQuestion instance) { + + } + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link PredicateDecisionQuestion}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public PredicateDecisionQuestion build() { + _checkSingleUse(); + + return new PredicateDecisionQuestion(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link PredicateDecisionQuestion} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, PredicateDecisionQuestion::setupPredicateDecisionQuestionDeserializer); + + protected static void setupPredicateDecisionQuestionDeserializer( + ObjectDeserializer op) { + DecisionQuestionBase.setupDecisionQuestionBaseDeserializer(op); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/ScoreDecisionQuestion.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/ScoreDecisionQuestion.java new file mode 100644 index 0000000000..879f7c20ac --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/decision/ScoreDecisionQuestion.java @@ -0,0 +1,206 @@ +/* + * 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.inference.decision; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +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 jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: inference.decision.ScoreDecisionQuestion + +/** + * A question answered with the probability-weighted position on an ordered + * scale of levels. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ScoreDecisionQuestion extends DecisionQuestionBase implements DecisionQuestionVariant { + private final List levels; + + // --------------------------------------------------------------------------------------------- + + private ScoreDecisionQuestion(Builder builder) { + super(builder); + + this.levels = ApiTypeHelper.unmodifiableRequired(builder.levels, this, "levels"); + + } + + public static ScoreDecisionQuestion of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * DecisionQuestion variant kind. + */ + @Override + public DecisionQuestion.Kind _decisionQuestionKind() { + return DecisionQuestion.Kind.Score; + } + + /** + * Required - The levels of the scale, ordered from lowest to highest. At least + * two levels are required. + *

+ * API name: {@code levels} + */ + public final List levels() { + return this.levels; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "score"); + super.serializeInternal(generator, mapper); + if (ApiTypeHelper.isDefined(this.levels)) { + generator.writeKey("levels"); + generator.writeStartArray(); + for (DecisionScoreLevel item0 : this.levels) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ScoreDecisionQuestion}. + */ + + public static class Builder extends DecisionQuestionBase.AbstractBuilder + implements + ObjectBuilder { + private List levels; + + public Builder() { + } + private Builder(ScoreDecisionQuestion instance) { + this.levels = instance.levels; + + } + /** + * Required - The levels of the scale, ordered from lowest to highest. At least + * two levels are required. + *

+ * API name: {@code levels} + *

+ * Adds all elements of list to levels. + */ + public final Builder levels(List list) { + this.levels = _listAddAll(this.levels, list); + return this; + } + + /** + * Required - The levels of the scale, ordered from lowest to highest. At least + * two levels are required. + *

+ * API name: {@code levels} + *

+ * Adds one or more values to levels. + */ + public final Builder levels(DecisionScoreLevel value, DecisionScoreLevel... values) { + this.levels = _listAdd(this.levels, value, values); + return this; + } + + /** + * Required - The levels of the scale, ordered from lowest to highest. At least + * two levels are required. + *

+ * API name: {@code levels} + *

+ * Adds a value to levels using a builder lambda. + */ + public final Builder levels(Function> fn) { + return levels(fn.apply(new DecisionScoreLevel.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ScoreDecisionQuestion}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ScoreDecisionQuestion build() { + _checkSingleUse(); + + return new ScoreDecisionQuestion(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ScoreDecisionQuestion} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ScoreDecisionQuestion::setupScoreDecisionQuestionDeserializer); + + protected static void setupScoreDecisionQuestionDeserializer(ObjectDeserializer op) { + DecisionQuestionBase.setupDecisionQuestionBaseDeserializer(op); + op.add(Builder::levels, JsonpDeserializer.arrayDeserializer(DecisionScoreLevel._DESERIALIZER), "levels"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentFormat.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentFormat.java new file mode 100644 index 0000000000..44dcb46476 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentFormat.java @@ -0,0 +1,67 @@ +/* + * 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.inference.document_extraction; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum DocumentExtractionContentFormat implements JsonEnum { + Base64("base64"), + + Url("url"), + + ; + + private final String jsonValue; + + DocumentExtractionContentFormat(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + DocumentExtractionContentFormat.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentObject.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentObject.java new file mode 100644 index 0000000000..91568f12aa --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentObject.java @@ -0,0 +1,185 @@ +/* + * 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.inference.document_extraction; + +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.JsonpUtils; +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.util.Objects; +import java.util.function.Function; +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: inference.document_extraction.DocumentExtractionContentObject + +/** + * A wrapper object which contains a single document to extract the content + * from. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DocumentExtractionContentObject implements JsonpSerializable { + private final DocumentExtractionContentObjectItem content; + + // --------------------------------------------------------------------------------------------- + + private DocumentExtractionContentObject(Builder builder) { + + this.content = ApiTypeHelper.requireNonNull(builder.content, this, "content"); + + } + + public static DocumentExtractionContentObject of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The document to extract the content from. + *

+ * API name: {@code content} + */ + public final DocumentExtractionContentObjectItem content() { + return this.content; + } + + /** + * 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("content"); + this.content.serialize(generator, mapper); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DocumentExtractionContentObject}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private DocumentExtractionContentObjectItem content; + + public Builder() { + } + private Builder(DocumentExtractionContentObject instance) { + this.content = instance.content; + + } + /** + * Required - The document to extract the content from. + *

+ * API name: {@code content} + */ + public final Builder content(DocumentExtractionContentObjectItem value) { + this.content = value; + return this; + } + + /** + * Required - The document to extract the content from. + *

+ * API name: {@code content} + */ + public final Builder content( + Function> fn) { + return this.content(fn.apply(new DocumentExtractionContentObjectItem.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DocumentExtractionContentObject}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DocumentExtractionContentObject build() { + _checkSingleUse(); + + return new DocumentExtractionContentObject(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DocumentExtractionContentObject} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DocumentExtractionContentObject::setupDocumentExtractionContentObjectDeserializer); + + protected static void setupDocumentExtractionContentObjectDeserializer( + ObjectDeserializer op) { + + op.add(Builder::content, DocumentExtractionContentObjectItem._DESERIALIZER, "content"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentObjectItem.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentObjectItem.java new file mode 100644 index 0000000000..6ff88e1438 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentObjectItem.java @@ -0,0 +1,253 @@ +/* + * 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.inference.document_extraction; + +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: inference.document_extraction.DocumentExtractionContentObjectItem + +/** + * An object describing a single document to extract the content from. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DocumentExtractionContentObjectItem implements JsonpSerializable { + private final DocumentExtractionContentType type; + + @Nullable + private final DocumentExtractionContentFormat format; + + private final String value; + + // --------------------------------------------------------------------------------------------- + + private DocumentExtractionContentObjectItem(Builder builder) { + + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.format = builder.format; + this.value = ApiTypeHelper.requireNonNull(builder.value, this, "value"); + + } + + public static DocumentExtractionContentObjectItem of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The type of the document. Not all services and models support all + * types. + *

+ * API name: {@code type} + */ + public final DocumentExtractionContentType type() { + return this.type; + } + + /** + * The format of the document. If not specified, this defaults to + * base64 for pdf and image, and + * url for html. The html type supports + * url only. Not all services and models support all formats. + *

+ * API name: {@code format} + */ + @Nullable + public final DocumentExtractionContentFormat format() { + return this.format; + } + + /** + * Required - The value of the document. For the base64 format, + * this must be a base64-encoded data URI, that is, + * "data:content/type;base64,...". For the url format, + * this must be a URL that points to the document, that is, "https://example.com/document.pdf". + *

+ * API name: {@code value} + */ + public final String value() { + return this.value; + } + + /** + * 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("type"); + this.type.serialize(generator, mapper); + if (this.format != null) { + generator.writeKey("format"); + this.format.serialize(generator, mapper); + } + generator.writeKey("value"); + generator.write(this.value); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DocumentExtractionContentObjectItem}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private DocumentExtractionContentType type; + + @Nullable + private DocumentExtractionContentFormat format; + + private String value; + + public Builder() { + } + private Builder(DocumentExtractionContentObjectItem instance) { + this.type = instance.type; + this.format = instance.format; + this.value = instance.value; + + } + /** + * Required - The type of the document. Not all services and models support all + * types. + *

+ * API name: {@code type} + */ + public final Builder type(DocumentExtractionContentType value) { + this.type = value; + return this; + } + + /** + * The format of the document. If not specified, this defaults to + * base64 for pdf and image, and + * url for html. The html type supports + * url only. Not all services and models support all formats. + *

+ * API name: {@code format} + */ + public final Builder format(@Nullable DocumentExtractionContentFormat value) { + this.format = value; + return this; + } + + /** + * Required - The value of the document. For the base64 format, + * this must be a base64-encoded data URI, that is, + * "data:content/type;base64,...". For the url format, + * this must be a URL that points to the document, that is, "https://example.com/document.pdf". + *

+ * API name: {@code value} + */ + public final Builder value(String value) { + this.value = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DocumentExtractionContentObjectItem}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DocumentExtractionContentObjectItem build() { + _checkSingleUse(); + + return new DocumentExtractionContentObjectItem(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DocumentExtractionContentObjectItem} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + DocumentExtractionContentObjectItem::setupDocumentExtractionContentObjectItemDeserializer); + + protected static void setupDocumentExtractionContentObjectItemDeserializer( + ObjectDeserializer op) { + + op.add(Builder::type, DocumentExtractionContentType._DESERIALIZER, "type"); + op.add(Builder::format, DocumentExtractionContentFormat._DESERIALIZER, "format"); + op.add(Builder::value, JsonpDeserializer.stringDeserializer(), "value"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentType.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentType.java new file mode 100644 index 0000000000..c7ed0b3094 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionContentType.java @@ -0,0 +1,69 @@ +/* + * 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.inference.document_extraction; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum DocumentExtractionContentType implements JsonEnum { + Image("image"), + + Pdf("pdf"), + + Html("html"), + + ; + + private final String jsonValue; + + DocumentExtractionContentType(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + DocumentExtractionContentType.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionOutputFormat.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionOutputFormat.java new file mode 100644 index 0000000000..27f7a105ac --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionOutputFormat.java @@ -0,0 +1,65 @@ +/* + * 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.inference.document_extraction; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum DocumentExtractionOutputFormat implements JsonEnum { + Markdown("markdown"), + + ; + + private final String jsonValue; + + DocumentExtractionOutputFormat(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + DocumentExtractionOutputFormat.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionTaskSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionTaskSettings.java new file mode 100644 index 0000000000..846d9c550f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/document_extraction/DocumentExtractionTaskSettings.java @@ -0,0 +1,245 @@ +/* + * 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.inference.document_extraction; + +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.JsonpUtils; +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.String; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +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: inference.document_extraction.DocumentExtractionTaskSettings + +/** + * Task settings for the document_extraction task type of the + * elastic service. They can be set when creating the inference + * endpoint and overridden per request. Request values take precedence, and + * parameters are merged per key. + * + * @see API + * specification + */ +@JsonpDeserializable +public class DocumentExtractionTaskSettings implements JsonpSerializable { + @Nullable + private final DocumentExtractionOutputFormat outputFormat; + + private final Map parameters; + + // --------------------------------------------------------------------------------------------- + + private DocumentExtractionTaskSettings(Builder builder) { + + this.outputFormat = builder.outputFormat; + this.parameters = ApiTypeHelper.unmodifiable(builder.parameters); + + } + + public static DocumentExtractionTaskSettings of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The output format of the extracted content. Only markdown is + * supported. + *

+ * API name: {@code output_format} + */ + @Nullable + public final DocumentExtractionOutputFormat outputFormat() { + return this.outputFormat; + } + + /** + * A free-form object of extraction options that is forwarded to the Elastic + * Inference Service as-is. The accepted parameters are defined by the Elastic + * Inference Service. + *

+ * API name: {@code parameters} + */ + public final Map parameters() { + return this.parameters; + } + + /** + * 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 (this.outputFormat != null) { + generator.writeKey("output_format"); + this.outputFormat.serialize(generator, mapper); + } + if (ApiTypeHelper.isDefined(this.parameters)) { + generator.writeKey("parameters"); + generator.writeStartObject(); + for (Map.Entry item0 : this.parameters.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DocumentExtractionTaskSettings}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private DocumentExtractionOutputFormat outputFormat; + + @Nullable + private Map parameters; + + public Builder() { + } + private Builder(DocumentExtractionTaskSettings instance) { + this.outputFormat = instance.outputFormat; + this.parameters = instance.parameters; + + } + /** + * The output format of the extracted content. Only markdown is + * supported. + *

+ * API name: {@code output_format} + */ + public final Builder outputFormat(@Nullable DocumentExtractionOutputFormat value) { + this.outputFormat = value; + return this; + } + + /** + * A free-form object of extraction options that is forwarded to the Elastic + * Inference Service as-is. The accepted parameters are defined by the Elastic + * Inference Service. + *

+ * API name: {@code parameters} + *

+ * Adds all entries of map to parameters. + */ + public final Builder parameters(Map map) { + this.parameters = _mapPutAll(this.parameters, map); + return this; + } + + /** + * A free-form object of extraction options that is forwarded to the Elastic + * Inference Service as-is. The accepted parameters are defined by the Elastic + * Inference Service. + *

+ * API name: {@code parameters} + *

+ * Adds an entry to parameters. + */ + public final Builder parameters(String key, JsonData value) { + this.parameters = _mapPut(this.parameters, key, value); + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DocumentExtractionTaskSettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DocumentExtractionTaskSettings build() { + _checkSingleUse(); + + return new DocumentExtractionTaskSettings(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DocumentExtractionTaskSettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DocumentExtractionTaskSettings::setupDocumentExtractionTaskSettingsDeserializer); + + protected static void setupDocumentExtractionTaskSettingsDeserializer( + ObjectDeserializer op) { + + op.add(Builder::outputFormat, DocumentExtractionOutputFormat._DESERIALIZER, "output_format"); + op.add(Builder::parameters, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "parameters"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/rerank/RerankInputFormat.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/rerank/RerankInputFormat.java index 9535e0fabe..410dd02a0a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/rerank/RerankInputFormat.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/rerank/RerankInputFormat.java @@ -50,6 +50,8 @@ public enum RerankInputFormat implements JsonEnum { Base64("base64"), + Url("url"), + ; private final String jsonValue; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/rerank/RerankInputObject.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/rerank/RerankInputObject.java index ceb548e169..614cb7c2db 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/rerank/RerankInputObject.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/rerank/RerankInputObject.java @@ -96,9 +96,11 @@ public final RerankInputType type() { /** * The format of the input. For the text type this must be * text. For the image type this must be - * base64. If not specified, this defaults to text for - * the text type and base64 for the image - * type. + * base64 or url. If not specified, this defaults to + * text for the text type and base64 for + * the image type. The url format is available in + * Elasticsearch 9.6.0 and later. Not all services and models support all + * formats. *

* API name: {@code format} */ @@ -108,8 +110,11 @@ public final RerankInputFormat format() { } /** - * Required - The value of the input. For images, this must be a base64-encoded - * data URI, that is, "data:content/type;base64,...". + * Required - The value of the input. For the base64 format, this + * must be a base64-encoded data URI, that is, + * "data:content/type;base64,...". For the url format, + * this must be a URL that points to the content, that is, "https://example.com/image.jpg". *

* API name: {@code value} */ @@ -180,9 +185,11 @@ public final Builder type(RerankInputType value) { /** * The format of the input. For the text type this must be * text. For the image type this must be - * base64. If not specified, this defaults to text for - * the text type and base64 for the image - * type. + * base64 or url. If not specified, this defaults to + * text for the text type and base64 for + * the image type. The url format is available in + * Elasticsearch 9.6.0 and later. Not all services and models support all + * formats. *

* API name: {@code format} */ @@ -192,8 +199,11 @@ public final Builder format(@Nullable RerankInputFormat value) { } /** - * Required - The value of the input. For images, this must be a base64-encoded - * data URI, that is, "data:content/type;base64,...". + * Required - The value of the input. For the base64 format, this + * must be a base64-encoded data URI, that is, + * "data:content/type;base64,...". For the url format, + * this must be a URL that points to the content, that is, "https://example.com/image.jpg". *

* API name: {@code value} */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/NormalizeForStreamProcessor.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/NormalizeForStreamProcessor.java new file mode 100644 index 0000000000..67bc8a5be1 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/NormalizeForStreamProcessor.java @@ -0,0 +1,127 @@ +/* + * 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.ingest; + +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.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: ingest._types.NormalizeForStreamProcessor + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class NormalizeForStreamProcessor extends ProcessorBase implements ProcessorVariant { + // --------------------------------------------------------------------------------------------- + + private NormalizeForStreamProcessor(Builder builder) { + super(builder); + + } + + public static NormalizeForStreamProcessor of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Processor variant kind. + */ + @Override + public Processor.Kind _processorKind() { + return Processor.Kind.NormalizeForStream; + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link NormalizeForStreamProcessor}. + */ + + public static class Builder extends ProcessorBase.AbstractBuilder + implements + ObjectBuilder { + public Builder() { + } + private Builder(NormalizeForStreamProcessor instance) { + + } + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link NormalizeForStreamProcessor}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public NormalizeForStreamProcessor build() { + _checkSingleUse(); + + return new NormalizeForStreamProcessor(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link NormalizeForStreamProcessor} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, NormalizeForStreamProcessor::setupNormalizeForStreamProcessorDeserializer); + + protected static void setupNormalizeForStreamProcessorDeserializer( + ObjectDeserializer op) { + ProcessorBase.setupProcessorBaseDeserializer(op); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/Processor.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/Processor.java index eee9a481e8..b0b5cab83b 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/Processor.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/Processor.java @@ -132,8 +132,12 @@ public enum Kind implements JsonEnum { NetworkDirection("network_direction"), + NormalizeForStream("normalize_for_stream"), + Pipeline("pipeline"), + RecoverFailureDocument("recover_failure_document"), + Redact("redact"), RegisteredDomain("registered_domain"), @@ -711,6 +715,24 @@ public NetworkDirectionProcessor networkDirection() { return TaggedUnionUtils.get(this, Kind.NetworkDirection); } + /** + * Is this variant instance of kind {@code normalize_for_stream}? + */ + public boolean isNormalizeForStream() { + return _kind == Kind.NormalizeForStream; + } + + /** + * Get the {@code normalize_for_stream} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code normalize_for_stream} + * kind. + */ + public NormalizeForStreamProcessor normalizeForStream() { + return TaggedUnionUtils.get(this, Kind.NormalizeForStream); + } + /** * Is this variant instance of kind {@code pipeline}? */ @@ -728,6 +750,24 @@ public PipelineProcessor pipeline() { return TaggedUnionUtils.get(this, Kind.Pipeline); } + /** + * Is this variant instance of kind {@code recover_failure_document}? + */ + public boolean isRecoverFailureDocument() { + return _kind == Kind.RecoverFailureDocument; + } + + /** + * Get the {@code recover_failure_document} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the + * {@code recover_failure_document} kind. + */ + public RecoverFailureDocumentProcessor recoverFailureDocument() { + return TaggedUnionUtils.get(this, Kind.RecoverFailureDocument); + } + /** * Is this variant instance of kind {@code redact}? */ @@ -1364,6 +1404,17 @@ public ObjectBuilder networkDirection( return this.networkDirection(fn.apply(new NetworkDirectionProcessor.Builder()).build()); } + public ObjectBuilder normalizeForStream(NormalizeForStreamProcessor v) { + this._kind = Kind.NormalizeForStream; + this._value = v; + return this; + } + + public ObjectBuilder normalizeForStream( + Function> fn) { + return this.normalizeForStream(fn.apply(new NormalizeForStreamProcessor.Builder()).build()); + } + public ObjectBuilder pipeline(PipelineProcessor v) { this._kind = Kind.Pipeline; this._value = v; @@ -1375,6 +1426,17 @@ public ObjectBuilder pipeline( return this.pipeline(fn.apply(new PipelineProcessor.Builder()).build()); } + public ObjectBuilder recoverFailureDocument(RecoverFailureDocumentProcessor v) { + this._kind = Kind.RecoverFailureDocument; + this._value = v; + return this; + } + + public ObjectBuilder recoverFailureDocument( + Function> fn) { + return this.recoverFailureDocument(fn.apply(new RecoverFailureDocumentProcessor.Builder()).build()); + } + public ObjectBuilder redact(RedactProcessor v) { this._kind = Kind.Redact; this._value = v; @@ -1597,7 +1659,10 @@ protected static void setupProcessorDeserializer(ObjectDeserializer op) op.add(Builder::kv, KeyValueProcessor._DESERIALIZER, "kv"); op.add(Builder::lowercase, LowercaseProcessor._DESERIALIZER, "lowercase"); op.add(Builder::networkDirection, NetworkDirectionProcessor._DESERIALIZER, "network_direction"); + op.add(Builder::normalizeForStream, NormalizeForStreamProcessor._DESERIALIZER, "normalize_for_stream"); op.add(Builder::pipeline, PipelineProcessor._DESERIALIZER, "pipeline"); + op.add(Builder::recoverFailureDocument, RecoverFailureDocumentProcessor._DESERIALIZER, + "recover_failure_document"); op.add(Builder::redact, RedactProcessor._DESERIALIZER, "redact"); op.add(Builder::registeredDomain, RegisteredDomainProcessor._DESERIALIZER, "registered_domain"); op.add(Builder::remove, RemoveProcessor._DESERIALIZER, "remove"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/ProcessorBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/ProcessorBuilders.java index 2ca6e86a49..1a37fd418b 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/ProcessorBuilders.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/ProcessorBuilders.java @@ -569,6 +569,25 @@ public static Processor networkDirection( return builder.build(); } + /** + * Creates a builder for the {@link NormalizeForStreamProcessor + * normalize_for_stream} {@code Processor} variant. + */ + public static NormalizeForStreamProcessor.Builder normalizeForStream() { + return new NormalizeForStreamProcessor.Builder(); + } + + /** + * Creates a Processor of the {@link NormalizeForStreamProcessor + * normalize_for_stream} {@code Processor} variant. + */ + public static Processor normalizeForStream( + Function> fn) { + Processor.Builder builder = new Processor.Builder(); + builder.normalizeForStream(fn.apply(new NormalizeForStreamProcessor.Builder()).build()); + return builder.build(); + } + /** * Creates a builder for the {@link PipelineProcessor pipeline} * {@code Processor} variant. @@ -587,6 +606,25 @@ public static Processor pipeline(Function> fn) { + Processor.Builder builder = new Processor.Builder(); + builder.recoverFailureDocument(fn.apply(new RecoverFailureDocumentProcessor.Builder()).build()); + return builder.build(); + } + /** * Creates a builder for the {@link RedactProcessor redact} {@code Processor} * variant. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/RecoverFailureDocumentProcessor.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/RecoverFailureDocumentProcessor.java new file mode 100644 index 0000000000..d435fb2e04 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/RecoverFailureDocumentProcessor.java @@ -0,0 +1,128 @@ +/* + * 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.ingest; + +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.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: ingest._types.RecoverFailureDocumentProcessor + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class RecoverFailureDocumentProcessor extends ProcessorBase implements ProcessorVariant { + // --------------------------------------------------------------------------------------------- + + private RecoverFailureDocumentProcessor(Builder builder) { + super(builder); + + } + + public static RecoverFailureDocumentProcessor of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Processor variant kind. + */ + @Override + public Processor.Kind _processorKind() { + return Processor.Kind.RecoverFailureDocument; + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RecoverFailureDocumentProcessor}. + */ + + public static class Builder extends ProcessorBase.AbstractBuilder + implements + ObjectBuilder { + public Builder() { + } + private Builder(RecoverFailureDocumentProcessor instance) { + + } + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link RecoverFailureDocumentProcessor}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RecoverFailureDocumentProcessor build() { + _checkSingleUse(); + + return new RecoverFailureDocumentProcessor(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RecoverFailureDocumentProcessor} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, RecoverFailureDocumentProcessor::setupRecoverFailureDocumentProcessorDeserializer); + + protected static void setupRecoverFailureDocumentProcessorDeserializer( + ObjectDeserializer op) { + ProcessorBase.setupProcessorBaseDeserializer(op); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/RenameProcessor.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/RenameProcessor.java index 9a32b5b493..970359d0d4 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/RenameProcessor.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ingest/RenameProcessor.java @@ -62,6 +62,9 @@ public class RenameProcessor extends ProcessorBase implements ProcessorVariant { @Nullable private final Boolean ignoreMissing; + @Nullable + private final Boolean override; + private final String targetField; // --------------------------------------------------------------------------------------------- @@ -71,6 +74,7 @@ private RenameProcessor(Builder builder) { this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); this.ignoreMissing = builder.ignoreMissing; + this.override = builder.override; this.targetField = ApiTypeHelper.requireNonNull(builder.targetField, this, "targetField"); } @@ -107,6 +111,18 @@ public final Boolean ignoreMissing() { return this.ignoreMissing; } + /** + * If true, the processor overwrites target_field if + * it already exists. If false, the processor fails when + * target_field already exists. + *

+ * API name: {@code override} + */ + @Nullable + public final Boolean override() { + return this.override; + } + /** * Required - The new name of the field. Supports template snippets. *

@@ -126,6 +142,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("ignore_missing"); generator.write(this.ignoreMissing); + } + if (this.override != null) { + generator.writeKey("override"); + generator.write(this.override); + } generator.writeKey("target_field"); generator.write(this.targetField); @@ -146,6 +167,9 @@ public static class Builder extends ProcessorBase.AbstractBuilder @Nullable private Boolean ignoreMissing; + @Nullable + private Boolean override; + private String targetField; public Builder() { @@ -153,6 +177,7 @@ public Builder() { private Builder(RenameProcessor instance) { this.field = instance.field; this.ignoreMissing = instance.ignoreMissing; + this.override = instance.override; this.targetField = instance.targetField; } @@ -177,6 +202,18 @@ public final Builder ignoreMissing(@Nullable Boolean value) { return this; } + /** + * If true, the processor overwrites target_field if + * it already exists. If false, the processor fails when + * target_field already exists. + *

+ * API name: {@code override} + */ + public final Builder override(@Nullable Boolean value) { + this.override = value; + return this; + } + /** * Required - The new name of the field. Supports template snippets. *

@@ -223,6 +260,7 @@ protected static void setupRenameProcessorDeserializer(ObjectDeserializer> ilmPolicies; + private final Map> repositories; + // --------------------------------------------------------------------------------------------- private DeprecationsResponse(Builder builder) { @@ -87,6 +89,7 @@ private DeprecationsResponse(Builder builder) { this.mlSettings = ApiTypeHelper.unmodifiableRequired(builder.mlSettings, this, "mlSettings"); this.templates = ApiTypeHelper.unmodifiableRequired(builder.templates, this, "templates"); this.ilmPolicies = ApiTypeHelper.unmodifiableRequired(builder.ilmPolicies, this, "ilmPolicies"); + this.repositories = ApiTypeHelper.unmodifiable(builder.repositories); } @@ -160,6 +163,15 @@ public final Map> ilmPolicies() { return this.ilmPolicies; } + /** + * Required - Snapshot repository warnings are sectioned off per repository. + *

+ * API name: {@code repositories} + */ + public final Map> repositories() { + return this.repositories; + } + /** * Serialize this object to JSON. */ @@ -273,6 +285,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } + if (ApiTypeHelper.isDefined(this.repositories)) { + generator.writeKey("repositories"); + generator.writeStartObject(); + for (Map.Entry> item0 : this.repositories.entrySet()) { + generator.writeKey(item0.getKey()); + generator.writeStartArray(); + if (item0.getValue() != null) { + for (Deprecation item1 : item0.getValue()) { + item1.serialize(generator, mapper); + + } + } + generator.writeEnd(); + + } + generator.writeEnd(); + + } } @@ -304,6 +334,9 @@ public static class Builder extends WithJsonObjectBuilderBase private Map> ilmPolicies; + @Nullable + private Map> repositories; + /** * Required - Cluster-level deprecation warnings. *

@@ -513,6 +546,30 @@ public final Builder ilmPolicies(String key, List value) { return this; } + /** + * Required - Snapshot repository warnings are sectioned off per repository. + *

+ * API name: {@code repositories} + *

+ * Adds all entries of map to repositories. + */ + public final Builder repositories(Map> map) { + this.repositories = _mapPutAll(this.repositories, map); + return this; + } + + /** + * Required - Snapshot repository warnings are sectioned off per repository. + *

+ * API name: {@code repositories} + *

+ * Adds an entry to repositories. + */ + public final Builder repositories(String key, List value) { + this.repositories = _mapPut(this.repositories, key, value); + return this; + } + @Override protected Builder self() { return this; @@ -557,6 +614,9 @@ protected static void setupDeprecationsResponseDeserializer(ObjectDeserializer * API name: {@code detectors} */ @@ -647,7 +647,7 @@ public final Builder description(@Nullable String value) { } /** - * An array of detector update objects. + * A detector update object or an array of detector update objects. *

* API name: {@code detectors} *

@@ -659,7 +659,7 @@ public final Builder detectors(List list) { } /** - * An array of detector update objects. + * A detector update object or an array of detector update objects. *

* API name: {@code detectors} *

@@ -671,7 +671,7 @@ public final Builder detectors(DetectorUpdate value, DetectorUpdate... values) { } /** - * An array of detector update objects. + * A detector update object or an array of detector update objects. *

* API name: {@code detectors} *

diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/HotThreadsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/HotThreadsRequest.java index bf4687be03..9565c5eb84 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/HotThreadsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/HotThreadsRequest.java @@ -21,6 +21,7 @@ import co.elastic.clients.elasticsearch._types.ErrorResponse; import co.elastic.clients.elasticsearch._types.RequestBase; +import co.elastic.clients.elasticsearch._types.ThreadSortOrder; import co.elastic.clients.elasticsearch._types.ThreadType; import co.elastic.clients.elasticsearch._types.Time; import co.elastic.clients.json.JsonpDeserializable; @@ -85,7 +86,7 @@ public class HotThreadsRequest extends RequestBase { private final Long snapshots; @Nullable - private final ThreadType sort; + private final ThreadSortOrder sort; @Nullable private final Long threads; @@ -161,7 +162,7 @@ public final Long snapshots() { * API name: {@code sort} */ @Nullable - public final ThreadType sort() { + public final ThreadSortOrder sort() { return this.sort; } @@ -218,7 +219,7 @@ public static class Builder extends RequestBase.AbstractBuilder private Long snapshots; @Nullable - private ThreadType sort; + private ThreadSortOrder sort; @Nullable private Long threads; @@ -311,7 +312,7 @@ public final Builder snapshots(@Nullable Long value) { *

* API name: {@code sort} */ - public final Builder sort(@Nullable ThreadType value) { + public final Builder sort(@Nullable ThreadSortOrder value) { this.sort = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ClearCacheRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ClearCacheRequest.java index d7164f1b37..23acf40e56 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ClearCacheRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ClearCacheRequest.java @@ -59,7 +59,7 @@ // typedef: searchable_snapshots.clear_cache.Request /** - * Clear the cache. + * Clear the searchable snapshots shared cache. *

* Clear indices and data streams from the shared cache for partially mounted * indices. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ElasticsearchSearchableSnapshotsAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ElasticsearchSearchableSnapshotsAsyncClient.java index 85c65302e4..21fc9cbd08 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ElasticsearchSearchableSnapshotsAsyncClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ElasticsearchSearchableSnapshotsAsyncClient.java @@ -123,7 +123,7 @@ public CompletableFuture cacheStats() { // ----- Endpoint: searchable_snapshots.clear_cache /** - * Clear the cache. + * Clear the searchable snapshots shared cache. *

* Clear indices and data streams from the shared cache for partially mounted * indices. @@ -141,7 +141,7 @@ public CompletableFuture clearCache(ClearCacheRequest reques } /** - * Clear the cache. + * Clear the searchable snapshots shared cache. *

* Clear indices and data streams from the shared cache for partially mounted * indices. @@ -160,7 +160,7 @@ public final CompletableFuture clearCache( } /** - * Clear the cache. + * Clear the searchable snapshots shared cache. *

* Clear indices and data streams from the shared cache for partially mounted * indices. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ElasticsearchSearchableSnapshotsClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ElasticsearchSearchableSnapshotsClient.java index df8b43b21a..8741ae8759 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ElasticsearchSearchableSnapshotsClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/searchable_snapshots/ElasticsearchSearchableSnapshotsClient.java @@ -123,7 +123,7 @@ public CacheStatsResponse cacheStats() throws IOException, ElasticsearchExceptio // ----- Endpoint: searchable_snapshots.clear_cache /** - * Clear the cache. + * Clear the searchable snapshots shared cache. *

* Clear indices and data streams from the shared cache for partially mounted * indices. @@ -141,7 +141,7 @@ public ClearCacheResponse clearCache(ClearCacheRequest request) throws IOExcepti } /** - * Clear the cache. + * Clear the searchable snapshots shared cache. *

* Clear indices and data streams from the shared cache for partially mounted * indices. @@ -160,7 +160,7 @@ public final ClearCacheResponse clearCache(Function * Clear indices and data streams from the shared cache for partially mounted * indices. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ApplicationGlobalUserPrivileges.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ApplicationGlobalUserPrivileges.java index 77a7567ec9..9bbc4d354f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ApplicationGlobalUserPrivileges.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ApplicationGlobalUserPrivileges.java @@ -26,7 +26,6 @@ import co.elastic.clients.json.JsonpUtils; 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; @@ -59,13 +58,14 @@ */ @JsonpDeserializable public class ApplicationGlobalUserPrivileges implements JsonpSerializable { + @Nullable private final ManageUserPrivileges manage; // --------------------------------------------------------------------------------------------- private ApplicationGlobalUserPrivileges(Builder builder) { - this.manage = ApiTypeHelper.requireNonNull(builder.manage, this, "manage"); + this.manage = builder.manage; } @@ -75,8 +75,12 @@ public static ApplicationGlobalUserPrivileges of( } /** - * Required - API name: {@code manage} + * The applications for which application privileges can be managed. Absent when + * the application section is present but grants no privileges. + *

+ * API name: {@code manage} */ + @Nullable public final ManageUserPrivileges manage() { return this.manage; } @@ -92,8 +96,11 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("manage"); - this.manage.serialize(generator, mapper); + if (this.manage != null) { + generator.writeKey("manage"); + this.manage.serialize(generator, mapper); + + } } @@ -111,6 +118,7 @@ public String toString() { public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable private ManageUserPrivileges manage; public Builder() { @@ -120,15 +128,21 @@ private Builder(ApplicationGlobalUserPrivileges instance) { } /** - * Required - API name: {@code manage} + * The applications for which application privileges can be managed. Absent when + * the application section is present but grants no privileges. + *

+ * API name: {@code manage} */ - public final Builder manage(ManageUserPrivileges value) { + public final Builder manage(@Nullable ManageUserPrivileges value) { this.manage = value; return this; } /** - * Required - API name: {@code manage} + * The applications for which application privileges can be managed. Absent when + * the application section is present but grants no privileges. + *

+ * API name: {@code manage} */ public final Builder manage(Function> fn) { return this.manage(fn.apply(new ManageUserPrivileges.Builder()).build()); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/CreateApiKeyRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/CreateApiKeyRequest.java index aca8d8a63b..267107e11d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/CreateApiKeyRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/CreateApiKeyRequest.java @@ -90,7 +90,6 @@ public class CreateApiKeyRequest extends RequestBase implements JsonpSerializabl private final Map metadata; - @Nullable private final String name; @Nullable @@ -104,7 +103,7 @@ private CreateApiKeyRequest(Builder builder) { this.expiration = builder.expiration; this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); - this.name = builder.name; + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.refresh = builder.refresh; this.roleDescriptors = ApiTypeHelper.unmodifiable(builder.roleDescriptors); @@ -136,11 +135,12 @@ public final Map metadata() { } /** - * A name for the API key. + * Required - A name for the API key. It is required, and it cannot be longer + * than 256 characters, begin or end with whitespace, or begin with an + * underscore. *

* API name: {@code name} */ - @Nullable public final String name() { return this.name; } @@ -207,11 +207,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } - if (this.name != null) { - generator.writeKey("name"); - generator.write(this.name); + generator.writeKey("name"); + generator.write(this.name); - } if (ApiTypeHelper.isDefined(this.roleDescriptors)) { generator.writeKey("role_descriptors"); generator.writeStartObject(); @@ -241,7 +239,6 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private Map metadata; - @Nullable private String name; @Nullable @@ -308,11 +305,13 @@ public final Builder metadata(String key, JsonData value) { } /** - * A name for the API key. + * Required - A name for the API key. It is required, and it cannot be longer + * than 256 characters, begin or end with whitespace, or begin with an + * underscore. *

* API name: {@code name} */ - public final Builder name(@Nullable String value) { + public final Builder name(String value) { this.name = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ElasticsearchSecurityAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ElasticsearchSecurityAsyncClient.java index 4a1eafd078..07d11359a9 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ElasticsearchSecurityAsyncClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ElasticsearchSecurityAsyncClient.java @@ -726,36 +726,6 @@ public final CompletableFuture createApiKey( return createApiKey(fn.apply(new CreateApiKeyRequest.Builder()).build()); } - /** - * Create an API key. - *

- * Create an API key for access without requiring basic authentication. - *

- * IMPORTANT: If the credential that is used to authenticate this request is an - * API key, the derived API key cannot have any privileges. If you specify - * privileges, the API returns an error. - *

- * A successful request returns a JSON structure that contains the API key, its - * unique id, and its name. If applicable, it also returns expiration - * information for the API key in milliseconds. - *

- * NOTE: By default, API keys never expire. You can specify expiration - * information when you create the API keys. - *

- * The API keys are created by the Elasticsearch API key service, which is - * automatically enabled. To configure or turn off the API key service, refer to - * API key service setting documentation. - * - * @see Documentation - * on elastic.co - */ - - public CompletableFuture createApiKey() { - return this.transport.performRequestAsync(new CreateApiKeyRequest.Builder().build(), - CreateApiKeyRequest._ENDPOINT, this.transportOptions); - } - // ----- Endpoint: security.create_cross_cluster_api_key /** @@ -2235,11 +2205,13 @@ public final CompletableFuture getUserProfile( *

  • username and password
  • *
  • Elasticsearch access tokens
  • *
  • JWTs
  • + *
  • service account tokens of user-managed service accounts
  • * *

    * The user, for whom the authentication credentials is provided, can optionally * "run as" (impersonate) another user. In this case, the API key will - * be created on behalf of the impersonated user. + * be created on behalf of the impersonated user. Run as is not supported with + * the _user_managed_service_account grant type. *

    * This API is intended be used by applications that need to create and manage * API keys for end users, but cannot guarantee that those users have permission @@ -2278,11 +2250,13 @@ public CompletableFuture grantApiKey(GrantApiKeyRequest req *

  • username and password
  • *
  • Elasticsearch access tokens
  • *
  • JWTs
  • + *
  • service account tokens of user-managed service accounts
  • * *

    * The user, for whom the authentication credentials is provided, can optionally * "run as" (impersonate) another user. In this case, the API key will - * be created on behalf of the impersonated user. + * be created on behalf of the impersonated user. Run as is not supported with + * the _user_managed_service_account grant type. *

    * This API is intended be used by applications that need to create and manage * API keys for end users, but cannot guarantee that those users have permission @@ -3349,6 +3323,64 @@ public CompletableFuture queryRole() { this.transportOptions); } + // ----- Endpoint: security.query_service_accounts + + /** + * Find user-managed service accounts with a query. + *

    + * Get a paginated list of user-managed service accounts and their information. + * You can optionally filter the results with a query. + *

    + * NOTE: Built-in service accounts are not stored in the security index, so this + * API never returns them. Use the get service accounts API to list them. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture queryServiceAccounts(QueryServiceAccountsRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) QueryServiceAccountsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Find user-managed service accounts with a query. + *

    + * Get a paginated list of user-managed service accounts and their information. + * You can optionally filter the results with a query. + *

    + * NOTE: Built-in service accounts are not stored in the security index, so this + * API never returns them. Use the get service accounts API to list them. + * + * @param fn + * a function that initializes a builder to create the + * {@link QueryServiceAccountsRequest} + * @see Documentation on elastic.co + */ + + public final CompletableFuture queryServiceAccounts( + Function> fn) { + return queryServiceAccounts(fn.apply(new QueryServiceAccountsRequest.Builder()).build()); + } + + /** + * Find user-managed service accounts with a query. + *

    + * Get a paginated list of user-managed service accounts and their information. + * You can optionally filter the results with a query. + *

    + * NOTE: Built-in service accounts are not stored in the security index, so this + * API never returns them. Use the get service accounts API to list them. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture queryServiceAccounts() { + return this.transport.performRequestAsync(new QueryServiceAccountsRequest.Builder().build(), + QueryServiceAccountsRequest._ENDPOINT, this.transportOptions); + } + // ----- Endpoint: security.query_user /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ElasticsearchSecurityClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ElasticsearchSecurityClient.java index cc9f7617d0..7a4b0c0fe0 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ElasticsearchSecurityClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ElasticsearchSecurityClient.java @@ -743,36 +743,6 @@ public final CreateApiKeyResponse createApiKey( return createApiKey(fn.apply(new CreateApiKeyRequest.Builder()).build()); } - /** - * Create an API key. - *

    - * Create an API key for access without requiring basic authentication. - *

    - * IMPORTANT: If the credential that is used to authenticate this request is an - * API key, the derived API key cannot have any privileges. If you specify - * privileges, the API returns an error. - *

    - * A successful request returns a JSON structure that contains the API key, its - * unique id, and its name. If applicable, it also returns expiration - * information for the API key in milliseconds. - *

    - * NOTE: By default, API keys never expire. You can specify expiration - * information when you create the API keys. - *

    - * The API keys are created by the Elasticsearch API key service, which is - * automatically enabled. To configure or turn off the API key service, refer to - * API key service setting documentation. - * - * @see Documentation - * on elastic.co - */ - - public CreateApiKeyResponse createApiKey() throws IOException, ElasticsearchException { - return this.transport.performRequest(new CreateApiKeyRequest.Builder().build(), CreateApiKeyRequest._ENDPOINT, - this.transportOptions); - } - // ----- Endpoint: security.create_cross_cluster_api_key /** @@ -2279,11 +2249,13 @@ public final GetUserProfileResponse getUserProfile( *

  • username and password
  • *
  • Elasticsearch access tokens
  • *
  • JWTs
  • + *
  • service account tokens of user-managed service accounts
  • * *

    * The user, for whom the authentication credentials is provided, can optionally * "run as" (impersonate) another user. In this case, the API key will - * be created on behalf of the impersonated user. + * be created on behalf of the impersonated user. Run as is not supported with + * the _user_managed_service_account grant type. *

    * This API is intended be used by applications that need to create and manage * API keys for end users, but cannot guarantee that those users have permission @@ -2322,11 +2294,13 @@ public GrantApiKeyResponse grantApiKey(GrantApiKeyRequest request) throws IOExce *

  • username and password
  • *
  • Elasticsearch access tokens
  • *
  • JWTs
  • + *
  • service account tokens of user-managed service accounts
  • * *

    * The user, for whom the authentication credentials is provided, can optionally * "run as" (impersonate) another user. In this case, the API key will - * be created on behalf of the impersonated user. + * be created on behalf of the impersonated user. Run as is not supported with + * the _user_managed_service_account grant type. *

    * This API is intended be used by applications that need to create and manage * API keys for end users, but cannot guarantee that those users have permission @@ -3410,6 +3384,66 @@ public QueryRoleResponse queryRole() throws IOException, ElasticsearchException this.transportOptions); } + // ----- Endpoint: security.query_service_accounts + + /** + * Find user-managed service accounts with a query. + *

    + * Get a paginated list of user-managed service accounts and their information. + * You can optionally filter the results with a query. + *

    + * NOTE: Built-in service accounts are not stored in the security index, so this + * API never returns them. Use the get service accounts API to list them. + * + * @see Documentation on elastic.co + */ + + public QueryServiceAccountsResponse queryServiceAccounts(QueryServiceAccountsRequest request) + throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) QueryServiceAccountsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Find user-managed service accounts with a query. + *

    + * Get a paginated list of user-managed service accounts and their information. + * You can optionally filter the results with a query. + *

    + * NOTE: Built-in service accounts are not stored in the security index, so this + * API never returns them. Use the get service accounts API to list them. + * + * @param fn + * a function that initializes a builder to create the + * {@link QueryServiceAccountsRequest} + * @see Documentation on elastic.co + */ + + public final QueryServiceAccountsResponse queryServiceAccounts( + Function> fn) + throws IOException, ElasticsearchException { + return queryServiceAccounts(fn.apply(new QueryServiceAccountsRequest.Builder()).build()); + } + + /** + * Find user-managed service accounts with a query. + *

    + * Get a paginated list of user-managed service accounts and their information. + * You can optionally filter the results with a query. + *

    + * NOTE: Built-in service accounts are not stored in the security index, so this + * API never returns them. Use the get service accounts API to list them. + * + * @see Documentation on elastic.co + */ + + public QueryServiceAccountsResponse queryServiceAccounts() throws IOException, ElasticsearchException { + return this.transport.performRequest(new QueryServiceAccountsRequest.Builder().build(), + QueryServiceAccountsRequest._ENDPOINT, this.transportOptions); + } + // ----- Endpoint: security.query_user /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetServiceAccountsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetServiceAccountsRequest.java index c1118977e7..f6f8c98d1b 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetServiceAccountsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetServiceAccountsRequest.java @@ -31,6 +31,7 @@ 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.HashMap; import java.util.List; @@ -84,6 +85,9 @@ public class GetServiceAccountsRequest extends RequestBase { private final List type; + @Nullable + private final Boolean withProfileUid; + // --------------------------------------------------------------------------------------------- private GetServiceAccountsRequest(Builder builder) { @@ -91,6 +95,7 @@ private GetServiceAccountsRequest(Builder builder) { this.namespace = builder.namespace; this.service = builder.service; this.type = ApiTypeHelper.unmodifiable(builder.type); + this.withProfileUid = builder.withProfileUid; } @@ -132,6 +137,20 @@ public final List type() { return this.type; } + /** + * If true, each user-managed service account also includes the + * profile UIDs of the users who created and last replaced it, under the + * created_by_profile_uid and updated_by_profile_uid + * fields. A profile UID is included only for a user who has an activated user + * profile. + *

    + * API name: {@code with_profile_uid} + */ + @Nullable + public final Boolean withProfileUid() { + return this.withProfileUid; + } + // --------------------------------------------------------------------------------------------- /** @@ -150,12 +169,16 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private List type; + @Nullable + private Boolean withProfileUid; + public Builder() { } private Builder(GetServiceAccountsRequest instance) { this.namespace = instance.namespace; this.service = instance.service; this.type = instance.type; + this.withProfileUid = instance.withProfileUid; } /** @@ -209,6 +232,20 @@ public final Builder type(ServiceAccountType value, ServiceAccountType... values return this; } + /** + * If true, each user-managed service account also includes the + * profile UIDs of the users who created and last replaced it, under the + * created_by_profile_uid and updated_by_profile_uid + * fields. A profile UID is included only for a user who has an activated user + * profile. + *

    + * API name: {@code with_profile_uid} + */ + public final Builder withProfileUid(@Nullable Boolean value) { + this.withProfileUid = value; + return this; + } + @Override protected Builder self() { return this; @@ -319,6 +356,9 @@ public Builder rebuild() { params.put("type", request.type.stream().map(v -> v.jsonValue()).filter(Objects::nonNull) .collect(Collectors.joining(","))); } + if (request.withProfileUid != null) { + params.put("with_profile_uid", String.valueOf(request.withProfileUid)); + } return params; }, SimpleEndpoint.emptyMap(), false, GetServiceAccountsResponse._DESERIALIZER); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GlobalPrivilege.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GlobalPrivilege.java index d0e841e620..03094c5fef 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GlobalPrivilege.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GlobalPrivilege.java @@ -62,6 +62,12 @@ public class GlobalPrivilege implements JsonpSerializable { @Nullable private final ApplicationGlobalUserPrivileges application; + @Nullable + private final WriteProfileGlobalUserPrivileges profile; + + @Nullable + private final ManageRolesGlobalUserPrivileges role; + private final List dataSource; // --------------------------------------------------------------------------------------------- @@ -69,6 +75,8 @@ public class GlobalPrivilege implements JsonpSerializable { private GlobalPrivilege(Builder builder) { this.application = builder.application; + this.profile = builder.profile; + this.role = builder.role; this.dataSource = ApiTypeHelper.unmodifiable(builder.dataSource); } @@ -85,6 +93,28 @@ public final ApplicationGlobalUserPrivileges application() { return this.application; } + /** + * A privilege that grants the ability to write the data and + * access sections of user profiles for the specified applications. + *

    + * API name: {@code profile} + */ + @Nullable + public final WriteProfileGlobalUserPrivileges profile() { + return this.profile; + } + + /** + * A privilege that grants the ability to manage roles that are scoped to the + * specified indices. + *

    + * API name: {@code role} + */ + @Nullable + public final ManageRolesGlobalUserPrivileges role() { + return this.role; + } + /** * A list of data source privilege entries, used to grant access to ES|QL data * sources. @@ -110,6 +140,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("application"); this.application.serialize(generator, mapper); + } + if (this.profile != null) { + generator.writeKey("profile"); + this.profile.serialize(generator, mapper); + + } + if (this.role != null) { + generator.writeKey("role"); + this.role.serialize(generator, mapper); + } if (ApiTypeHelper.isDefined(this.dataSource)) { generator.writeKey("data_source"); @@ -139,6 +179,12 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private ApplicationGlobalUserPrivileges application; + @Nullable + private WriteProfileGlobalUserPrivileges profile; + + @Nullable + private ManageRolesGlobalUserPrivileges role; + @Nullable private List dataSource; @@ -146,6 +192,8 @@ public Builder() { } private Builder(GlobalPrivilege instance) { this.application = instance.application; + this.profile = instance.profile; + this.role = instance.role; this.dataSource = instance.dataSource; } @@ -165,6 +213,50 @@ public final Builder application( return this.application(fn.apply(new ApplicationGlobalUserPrivileges.Builder()).build()); } + /** + * A privilege that grants the ability to write the data and + * access sections of user profiles for the specified applications. + *

    + * API name: {@code profile} + */ + public final Builder profile(@Nullable WriteProfileGlobalUserPrivileges value) { + this.profile = value; + return this; + } + + /** + * A privilege that grants the ability to write the data and + * access sections of user profiles for the specified applications. + *

    + * API name: {@code profile} + */ + public final Builder profile( + Function> fn) { + return this.profile(fn.apply(new WriteProfileGlobalUserPrivileges.Builder()).build()); + } + + /** + * A privilege that grants the ability to manage roles that are scoped to the + * specified indices. + *

    + * API name: {@code role} + */ + public final Builder role(@Nullable ManageRolesGlobalUserPrivileges value) { + this.role = value; + return this; + } + + /** + * A privilege that grants the ability to manage roles that are scoped to the + * specified indices. + *

    + * API name: {@code role} + */ + public final Builder role( + Function> fn) { + return this.role(fn.apply(new ManageRolesGlobalUserPrivileges.Builder()).build()); + } + /** * A list of data source privilege entries, used to grant access to ES|QL data * sources. @@ -239,6 +331,8 @@ public Builder rebuild() { protected static void setupGlobalPrivilegeDeserializer(ObjectDeserializer op) { op.add(Builder::application, ApplicationGlobalUserPrivileges._DESERIALIZER, "application"); + op.add(Builder::profile, WriteProfileGlobalUserPrivileges._DESERIALIZER, "profile"); + op.add(Builder::role, ManageRolesGlobalUserPrivileges._DESERIALIZER, "role"); op.add(Builder::dataSource, JsonpDeserializer.arrayDeserializer(DataSourcePrivileges._DESERIALIZER), "data_source"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GrantApiKeyRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GrantApiKeyRequest.java index 3fe88b206d..1ba9e66824 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GrantApiKeyRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GrantApiKeyRequest.java @@ -24,6 +24,7 @@ import co.elastic.clients.elasticsearch._types.RequestBase; import co.elastic.clients.elasticsearch.security.grant_api_key.ApiKeyGrantType; import co.elastic.clients.elasticsearch.security.grant_api_key.GrantApiKey; +import co.elastic.clients.elasticsearch.security.grant_api_key.GrantApiKeyClientAuthentication; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -73,11 +74,13 @@ *

  • username and password
  • *
  • Elasticsearch access tokens
  • *
  • JWTs
  • + *
  • service account tokens of user-managed service accounts
  • * *

    * The user, for whom the authentication credentials is provided, can optionally * "run as" (impersonate) another user. In this case, the API key will - * be created on behalf of the impersonated user. + * be created on behalf of the impersonated user. Run as is not supported with + * the _user_managed_service_account grant type. *

    * This API is intended be used by applications that need to create and manage * API keys for end users, but cannot guarantee that those users have permission @@ -101,6 +104,9 @@ public class GrantApiKeyRequest extends RequestBase implements JsonpSerializable private final GrantApiKey apiKey; + @Nullable + private final GrantApiKeyClientAuthentication clientAuthentication; + private final ApiKeyGrantType grantType; @Nullable @@ -112,6 +118,9 @@ public class GrantApiKeyRequest extends RequestBase implements JsonpSerializable @Nullable private final String runAs; + @Nullable + private final String serviceAccountToken; + @Nullable private final String username; @@ -121,10 +130,12 @@ private GrantApiKeyRequest(Builder builder) { this.accessToken = builder.accessToken; this.apiKey = ApiTypeHelper.requireNonNull(builder.apiKey, this, "apiKey"); + this.clientAuthentication = builder.clientAuthentication; this.grantType = ApiTypeHelper.requireNonNull(builder.grantType, this, "grantType"); this.password = builder.password; this.refresh = builder.refresh; this.runAs = builder.runAs; + this.serviceAccountToken = builder.serviceAccountToken; this.username = builder.username; } @@ -153,9 +164,23 @@ public final GrantApiKey apiKey() { return this.apiKey; } + /** + * The client authentication for a JWT that requires it, which is what is + * normally sent in the ES-Client-Authentication request header. It + * is valid only with the access_token grant type, when the access + * token is a JWT. + *

    + * API name: {@code client_authentication} + */ + @Nullable + public final GrantApiKeyClientAuthentication clientAuthentication() { + return this.clientAuthentication; + } + /** * Required - The type of grant. Supported grant types are: - * access_token, password. + * access_token, password, and + * _user_managed_service_account. *

    * API name: {@code grant_type} */ @@ -187,7 +212,8 @@ public final Refresh refresh() { } /** - * The name of the user to be impersonated. + * The name of the user to be impersonated. It is not valid with the + * _user_managed_service_account grant type. *

    * API name: {@code run_as} */ @@ -196,6 +222,19 @@ public final String runAs() { return this.runAs; } + /** + * The service account token of a user-managed service account, as returned by + * the create service account token API. If you specify the + * _user_managed_service_account grant type, this parameter is + * required. It is not valid with other grant types. + *

    + * API name: {@code service_account_token} + */ + @Nullable + public final String serviceAccountToken() { + return this.serviceAccountToken; + } + /** * The user name that identifies the user. If you specify the * password grant type, this parameter is required. It is not valid @@ -227,6 +266,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("api_key"); this.apiKey.serialize(generator, mapper); + if (this.clientAuthentication != null) { + generator.writeKey("client_authentication"); + this.clientAuthentication.serialize(generator, mapper); + + } generator.writeKey("grant_type"); this.grantType.serialize(generator, mapper); if (this.password != null) { @@ -238,6 +282,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("run_as"); generator.write(this.runAs); + } + if (this.serviceAccountToken != null) { + generator.writeKey("service_account_token"); + generator.write(this.serviceAccountToken); + } if (this.username != null) { generator.writeKey("username"); @@ -261,6 +310,9 @@ public static class Builder extends RequestBase.AbstractBuilder private GrantApiKey apiKey; + @Nullable + private GrantApiKeyClientAuthentication clientAuthentication; + private ApiKeyGrantType grantType; @Nullable @@ -272,6 +324,9 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private String runAs; + @Nullable + private String serviceAccountToken; + @Nullable private String username; @@ -280,10 +335,12 @@ public Builder() { private Builder(GrantApiKeyRequest instance) { this.accessToken = instance.accessToken; this.apiKey = instance.apiKey; + this.clientAuthentication = instance.clientAuthentication; this.grantType = instance.grantType; this.password = instance.password; this.refresh = instance.refresh; this.runAs = instance.runAs; + this.serviceAccountToken = instance.serviceAccountToken; this.username = instance.username; } @@ -317,9 +374,36 @@ public final Builder apiKey(FunctionES-Client-Authentication request header. It + * is valid only with the access_token grant type, when the access + * token is a JWT. + *

    + * API name: {@code client_authentication} + */ + public final Builder clientAuthentication(@Nullable GrantApiKeyClientAuthentication value) { + this.clientAuthentication = value; + return this; + } + + /** + * The client authentication for a JWT that requires it, which is what is + * normally sent in the ES-Client-Authentication request header. It + * is valid only with the access_token grant type, when the access + * token is a JWT. + *

    + * API name: {@code client_authentication} + */ + public final Builder clientAuthentication( + Function> fn) { + return this.clientAuthentication(fn.apply(new GrantApiKeyClientAuthentication.Builder()).build()); + } + /** * Required - The type of grant. Supported grant types are: - * access_token, password. + * access_token, password, and + * _user_managed_service_account. *

    * API name: {@code grant_type} */ @@ -352,7 +436,8 @@ public final Builder refresh(@Nullable Refresh value) { } /** - * The name of the user to be impersonated. + * The name of the user to be impersonated. It is not valid with the + * _user_managed_service_account grant type. *

    * API name: {@code run_as} */ @@ -361,6 +446,19 @@ public final Builder runAs(@Nullable String value) { return this; } + /** + * The service account token of a user-managed service account, as returned by + * the create service account token API. If you specify the + * _user_managed_service_account grant type, this parameter is + * required. It is not valid with other grant types. + *

    + * API name: {@code service_account_token} + */ + public final Builder serviceAccountToken(@Nullable String value) { + this.serviceAccountToken = value; + return this; + } + /** * The user name that identifies the user. If you specify the * password grant type, this parameter is required. It is not valid @@ -409,9 +507,11 @@ protected static void setupGrantApiKeyRequestDeserializer(ObjectDeserializerAPI + * specification + */ +@JsonpDeserializable +public class ManageRolesGlobalUserPrivileges implements JsonpSerializable { + @Nullable + private final ManageRolesPrivileges manage; + + // --------------------------------------------------------------------------------------------- + + private ManageRolesGlobalUserPrivileges(Builder builder) { + + this.manage = builder.manage; + + } + + public static ManageRolesGlobalUserPrivileges of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The index-scoped role management privileges. Absent when the + * role section is present but grants no privileges. + *

    + * API name: {@code manage} + */ + @Nullable + public final ManageRolesPrivileges manage() { + return this.manage; + } + + /** + * 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 (this.manage != null) { + generator.writeKey("manage"); + this.manage.serialize(generator, mapper); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ManageRolesGlobalUserPrivileges}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private ManageRolesPrivileges manage; + + public Builder() { + } + private Builder(ManageRolesGlobalUserPrivileges instance) { + this.manage = instance.manage; + + } + /** + * The index-scoped role management privileges. Absent when the + * role section is present but grants no privileges. + *

    + * API name: {@code manage} + */ + public final Builder manage(@Nullable ManageRolesPrivileges value) { + this.manage = value; + return this; + } + + /** + * The index-scoped role management privileges. Absent when the + * role section is present but grants no privileges. + *

    + * API name: {@code manage} + */ + public final Builder manage(Function> fn) { + return this.manage(fn.apply(new ManageRolesPrivileges.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ManageRolesGlobalUserPrivileges}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ManageRolesGlobalUserPrivileges build() { + _checkSingleUse(); + + return new ManageRolesGlobalUserPrivileges(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ManageRolesGlobalUserPrivileges} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ManageRolesGlobalUserPrivileges::setupManageRolesGlobalUserPrivilegesDeserializer); + + protected static void setupManageRolesGlobalUserPrivilegesDeserializer( + ObjectDeserializer op) { + + op.add(Builder::manage, ManageRolesPrivileges._DESERIALIZER, "manage"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ManageRolesIndexPermissions.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ManageRolesIndexPermissions.java new file mode 100644 index 0000000000..0503d2067d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ManageRolesIndexPermissions.java @@ -0,0 +1,253 @@ +/* + * 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.security; + +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.JsonpUtils; +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.String; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: security._types.ManageRolesIndexPermissions + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ManageRolesIndexPermissions implements JsonpSerializable { + private final List names; + + private final List privileges; + + // --------------------------------------------------------------------------------------------- + + private ManageRolesIndexPermissions(Builder builder) { + + this.names = ApiTypeHelper.unmodifiableRequired(builder.names, this, "names"); + this.privileges = ApiTypeHelper.unmodifiableRequired(builder.privileges, this, "privileges"); + + } + + public static ManageRolesIndexPermissions of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - A list of indices (or index name patterns) that the owners of the + * role can manage roles for. + *

    + * API name: {@code names} + */ + public final List names() { + return this.names; + } + + /** + * Required - The index privileges that the managed roles are allowed to grant + * on the specified indices. + *

    + * API name: {@code privileges} + */ + public final List privileges() { + return this.privileges; + } + + /** + * 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.names)) { + generator.writeKey("names"); + generator.writeStartArray(); + for (String item0 : this.names) { + generator.write(item0); + + } + generator.writeEnd(); + + } + if (ApiTypeHelper.isDefined(this.privileges)) { + generator.writeKey("privileges"); + generator.writeStartArray(); + for (String item0 : this.privileges) { + generator.write(item0); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ManageRolesIndexPermissions}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private List names; + + private List privileges; + + public Builder() { + } + private Builder(ManageRolesIndexPermissions instance) { + this.names = instance.names; + this.privileges = instance.privileges; + + } + /** + * Required - A list of indices (or index name patterns) that the owners of the + * role can manage roles for. + *

    + * API name: {@code names} + *

    + * Adds all elements of list to names. + */ + public final Builder names(List list) { + this.names = _listAddAll(this.names, list); + return this; + } + + /** + * Required - A list of indices (or index name patterns) that the owners of the + * role can manage roles for. + *

    + * API name: {@code names} + *

    + * Adds one or more values to names. + */ + public final Builder names(String value, String... values) { + this.names = _listAdd(this.names, value, values); + return this; + } + + /** + * Required - The index privileges that the managed roles are allowed to grant + * on the specified indices. + *

    + * API name: {@code privileges} + *

    + * Adds all elements of list to privileges. + */ + public final Builder privileges(List list) { + this.privileges = _listAddAll(this.privileges, list); + return this; + } + + /** + * Required - The index privileges that the managed roles are allowed to grant + * on the specified indices. + *

    + * API name: {@code privileges} + *

    + * Adds one or more values to privileges. + */ + public final Builder privileges(String value, String... values) { + this.privileges = _listAdd(this.privileges, value, values); + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ManageRolesIndexPermissions}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ManageRolesIndexPermissions build() { + _checkSingleUse(); + + return new ManageRolesIndexPermissions(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ManageRolesIndexPermissions} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ManageRolesIndexPermissions::setupManageRolesIndexPermissionsDeserializer); + + protected static void setupManageRolesIndexPermissionsDeserializer( + ObjectDeserializer op) { + + op.add(Builder::names, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "names"); + op.add(Builder::privileges, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "privileges"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ManageRolesPrivileges.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ManageRolesPrivileges.java new file mode 100644 index 0000000000..350984b9df --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ManageRolesPrivileges.java @@ -0,0 +1,199 @@ +/* + * 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.security; + +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.JsonpUtils; +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.util.List; +import java.util.Objects; +import java.util.function.Function; +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: security._types.ManageRolesPrivileges + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ManageRolesPrivileges implements JsonpSerializable { + private final List indices; + + // --------------------------------------------------------------------------------------------- + + private ManageRolesPrivileges(Builder builder) { + + this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); + + } + + public static ManageRolesPrivileges of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code indices} + */ + public final List indices() { + return this.indices; + } + + /** + * 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.indices)) { + generator.writeKey("indices"); + generator.writeStartArray(); + for (ManageRolesIndexPermissions item0 : this.indices) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ManageRolesPrivileges}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private List indices; + + public Builder() { + } + private Builder(ManageRolesPrivileges instance) { + this.indices = instance.indices; + + } + /** + * Required - API name: {@code indices} + *

    + * Adds all elements of list to indices. + */ + public final Builder indices(List list) { + this.indices = _listAddAll(this.indices, list); + return this; + } + + /** + * Required - API name: {@code indices} + *

    + * Adds one or more values to indices. + */ + public final Builder indices(ManageRolesIndexPermissions value, ManageRolesIndexPermissions... values) { + this.indices = _listAdd(this.indices, value, values); + return this; + } + + /** + * Required - API name: {@code indices} + *

    + * Adds a value to indices using a builder lambda. + */ + public final Builder indices( + Function> fn) { + return indices(fn.apply(new ManageRolesIndexPermissions.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ManageRolesPrivileges}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ManageRolesPrivileges build() { + _checkSingleUse(); + + return new ManageRolesPrivileges(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ManageRolesPrivileges} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ManageRolesPrivileges::setupManageRolesPrivilegesDeserializer); + + protected static void setupManageRolesPrivilegesDeserializer(ObjectDeserializer op) { + + op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(ManageRolesIndexPermissions._DESERIALIZER), + "indices"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/PutUserManagedServiceAccountRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/PutUserManagedServiceAccountRequest.java index 1355f0ce0a..a981e99629 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/PutUserManagedServiceAccountRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/PutUserManagedServiceAccountRequest.java @@ -80,6 +80,9 @@ */ @JsonpDeserializable public class PutUserManagedServiceAccountRequest extends RequestBase implements JsonpSerializable { + @Nullable + private final String description; + @Nullable private final Boolean enabled; @@ -96,6 +99,7 @@ public class PutUserManagedServiceAccountRequest extends RequestBase implements private PutUserManagedServiceAccountRequest(Builder builder) { + this.description = builder.description; this.enabled = builder.enabled; this.namespace = ApiTypeHelper.requireNonNull(builder.namespace, this, "namespace"); this.refresh = builder.refresh; @@ -109,6 +113,18 @@ public static PutUserManagedServiceAccountRequest of( return fn.apply(new Builder()).build(); } + /** + * A free-text description of the account, as sent on the last PUT of the + * account. It has no meaning to Elasticsearch. Absent when the account has no + * description. + *

    + * API name: {@code description} + */ + @Nullable + public final String description() { + return this.description; + } + /** * Whether the account can authenticate. Tokens can still be created for a * disabled account; they just cannot be used until the account is enabled. @@ -178,6 +194,11 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.description != null) { + generator.writeKey("description"); + generator.write(this.description); + + } if (this.enabled != null) { generator.writeKey("enabled"); generator.write(this.enabled); @@ -205,6 +226,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends RequestBase.AbstractBuilder implements ObjectBuilder { + @Nullable + private String description; + @Nullable private Boolean enabled; @@ -220,6 +244,7 @@ public static class Builder extends RequestBase.AbstractBuilder public Builder() { } private Builder(PutUserManagedServiceAccountRequest instance) { + this.description = instance.description; this.enabled = instance.enabled; this.namespace = instance.namespace; this.refresh = instance.refresh; @@ -227,6 +252,18 @@ private Builder(PutUserManagedServiceAccountRequest instance) { this.service = instance.service; } + /** + * A free-text description of the account, as sent on the last PUT of the + * account. It has no meaning to Elasticsearch. Absent when the account has no + * description. + *

    + * API name: {@code description} + */ + public final Builder description(@Nullable String value) { + this.description = value; + return this; + } + /** * Whether the account can authenticate. Tokens can still be created for a * disabled account; they just cannot be used until the account is enabled. @@ -340,6 +377,7 @@ public Builder rebuild() { protected static void setupPutUserManagedServiceAccountRequestDeserializer( ObjectDeserializer op) { + op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description"); op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "roles"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/QueryServiceAccountsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/QueryServiceAccountsRequest.java new file mode 100644 index 0000000000..17b644f410 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/QueryServiceAccountsRequest.java @@ -0,0 +1,626 @@ +/* + * 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.security; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.FieldValue; +import co.elastic.clients.elasticsearch._types.RequestBase; +import co.elastic.clients.elasticsearch._types.SortOptions; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQuery; +import co.elastic.clients.elasticsearch.security.query_service_accounts.ServiceAccountQueryVariant; +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.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.Integer; +import java.lang.String; +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 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: security.query_service_accounts.Request + +/** + * Find user-managed service accounts with a query. + *

    + * Get a paginated list of user-managed service accounts and their information. + * You can optionally filter the results with a query. + *

    + * NOTE: Built-in service accounts are not stored in the security index, so this + * API never returns them. Use the get service accounts API to list them. + * + * @see API + * specification + */ +@JsonpDeserializable +public class QueryServiceAccountsRequest extends RequestBase implements JsonpSerializable { + @Nullable + private final Integer from; + + @Nullable + private final ServiceAccountQuery query; + + private final List searchAfter; + + @Nullable + private final Integer size; + + private final List sort; + + @Nullable + private final Boolean withProfileUid; + + // --------------------------------------------------------------------------------------------- + + private QueryServiceAccountsRequest(Builder builder) { + + this.from = builder.from; + this.query = builder.query; + this.searchAfter = ApiTypeHelper.unmodifiable(builder.searchAfter); + this.size = builder.size; + this.sort = ApiTypeHelper.unmodifiable(builder.sort); + this.withProfileUid = builder.withProfileUid; + + } + + public static QueryServiceAccountsRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The starting document offset. It must not be negative. By default, you cannot + * page through more than 10,000 hits using the from and + * size parameters. To page through more hits, use the + * search_after parameter. + *

    + * API name: {@code from} + */ + @Nullable + public final Integer from() { + return this.from; + } + + /** + * A query to filter which service accounts to return. If the query parameter is + * missing, it is equivalent to a match_all query. The query + * supports a subset of query types, including match_all, + * bool, term, terms, match, + * ids, prefix, wildcard, + * exists, range, and + * simple_query_string. You can query the following information + * associated with a service account: username, roles, + * enabled, description, + * created_by.username, created_by.realm, + * created_by.realm_type, created_by.api_key.id, + * created_by.api_key.name, created_at, + * updated_by.username, updated_by.realm, + * updated_by.realm_type, updated_by.api_key.id, + * updated_by.api_key.name, and updated_at. + *

    + * NOTE: The username of a service account is its + * namespace/service pair, so use a prefix query on + * username to select a namespace. + *

    + * API name: {@code query} + */ + @Nullable + public final ServiceAccountQuery query() { + return this.query; + } + + /** + * The search after definition. + *

    + * API name: {@code search_after} + */ + public final List searchAfter() { + return this.searchAfter; + } + + /** + * The number of hits to return. It must not be negative. By default, you cannot + * page through more than 10,000 hits using the from and + * size parameters. To page through more hits, use the + * search_after parameter. + *

    + * API name: {@code size} + */ + @Nullable + public final Integer size() { + return this.size; + } + + /** + * The sort definition. All the fields that you can query on, other than + * description, are eligible for sorting. In addition, sort can + * also be applied to the _doc field to sort by index order. + *

    + * API name: {@code sort} + */ + public final List sort() { + return this.sort; + } + + /** + * If true, each service account also includes the profile UIDs of + * the users who created and last replaced it, under the + * created_by_profile_uid and updated_by_profile_uid + * fields. A profile UID is included only for a user who has an activated user + * profile. + *

    + * API name: {@code with_profile_uid} + */ + @Nullable + public final Boolean withProfileUid() { + return this.withProfileUid; + } + + /** + * 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 (this.from != null) { + generator.writeKey("from"); + generator.write(this.from); + + } + if (this.query != null) { + generator.writeKey("query"); + this.query.serialize(generator, mapper); + + } + if (ApiTypeHelper.isDefined(this.searchAfter)) { + generator.writeKey("search_after"); + generator.writeStartArray(); + for (FieldValue item0 : this.searchAfter) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (this.size != null) { + generator.writeKey("size"); + generator.write(this.size); + + } + if (ApiTypeHelper.isDefined(this.sort)) { + generator.writeKey("sort"); + generator.writeStartArray(); + for (SortOptions item0 : this.sort) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link QueryServiceAccountsRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private Integer from; + + @Nullable + private ServiceAccountQuery query; + + @Nullable + private List searchAfter; + + @Nullable + private Integer size; + + @Nullable + private List sort; + + @Nullable + private Boolean withProfileUid; + + public Builder() { + } + private Builder(QueryServiceAccountsRequest instance) { + this.from = instance.from; + this.query = instance.query; + this.searchAfter = instance.searchAfter; + this.size = instance.size; + this.sort = instance.sort; + this.withProfileUid = instance.withProfileUid; + + } + /** + * The starting document offset. It must not be negative. By default, you cannot + * page through more than 10,000 hits using the from and + * size parameters. To page through more hits, use the + * search_after parameter. + *

    + * API name: {@code from} + */ + public final Builder from(@Nullable Integer value) { + this.from = value; + return this; + } + + /** + * A query to filter which service accounts to return. If the query parameter is + * missing, it is equivalent to a match_all query. The query + * supports a subset of query types, including match_all, + * bool, term, terms, match, + * ids, prefix, wildcard, + * exists, range, and + * simple_query_string. You can query the following information + * associated with a service account: username, roles, + * enabled, description, + * created_by.username, created_by.realm, + * created_by.realm_type, created_by.api_key.id, + * created_by.api_key.name, created_at, + * updated_by.username, updated_by.realm, + * updated_by.realm_type, updated_by.api_key.id, + * updated_by.api_key.name, and updated_at. + *

    + * NOTE: The username of a service account is its + * namespace/service pair, so use a prefix query on + * username to select a namespace. + *

    + * API name: {@code query} + */ + public final Builder query(@Nullable ServiceAccountQuery value) { + this.query = value; + return this; + } + + /** + * A query to filter which service accounts to return. If the query parameter is + * missing, it is equivalent to a match_all query. The query + * supports a subset of query types, including match_all, + * bool, term, terms, match, + * ids, prefix, wildcard, + * exists, range, and + * simple_query_string. You can query the following information + * associated with a service account: username, roles, + * enabled, description, + * created_by.username, created_by.realm, + * created_by.realm_type, created_by.api_key.id, + * created_by.api_key.name, created_at, + * updated_by.username, updated_by.realm, + * updated_by.realm_type, updated_by.api_key.id, + * updated_by.api_key.name, and updated_at. + *

    + * NOTE: The username of a service account is its + * namespace/service pair, so use a prefix query on + * username to select a namespace. + *

    + * API name: {@code query} + */ + public final Builder query(Function> fn) { + return this.query(fn.apply(new ServiceAccountQuery.Builder()).build()); + } + + /** + * A query to filter which service accounts to return. If the query parameter is + * missing, it is equivalent to a match_all query. The query + * supports a subset of query types, including match_all, + * bool, term, terms, match, + * ids, prefix, wildcard, + * exists, range, and + * simple_query_string. You can query the following information + * associated with a service account: username, roles, + * enabled, description, + * created_by.username, created_by.realm, + * created_by.realm_type, created_by.api_key.id, + * created_by.api_key.name, created_at, + * updated_by.username, updated_by.realm, + * updated_by.realm_type, updated_by.api_key.id, + * updated_by.api_key.name, and updated_at. + *

    + * NOTE: The username of a service account is its + * namespace/service pair, so use a prefix query on + * username to select a namespace. + *

    + * API name: {@code query} + */ + public final Builder query(ServiceAccountQueryVariant value) { + this.query = value._toServiceAccountQuery(); + return this; + } + + /** + * The search after definition. + *

    + * API name: {@code search_after} + *

    + * Adds all elements of list to searchAfter. + */ + public final Builder searchAfter(List list) { + this.searchAfter = _listAddAll(this.searchAfter, list); + return this; + } + + /** + * The search after definition. + *

    + * API name: {@code search_after} + *

    + * Adds one or more values to searchAfter. + */ + public final Builder searchAfter(FieldValue value, FieldValue... values) { + this.searchAfter = _listAdd(this.searchAfter, value, values); + return this; + } + + /** + * The search after definition. + *

    + * API name: {@code search_after} + *

    + * Adds one or more values to searchAfter. + */ + public final Builder searchAfter(String value, String... values) { + this.searchAfter = _listAdd(this.searchAfter, FieldValue.of(value)); + for (String v : values) { + _listAdd(this.searchAfter, FieldValue.of(v)); + } + return this; + } + + /** + * The search after definition. + *

    + * API name: {@code search_after} + *

    + * Adds one or more values to searchAfter. + */ + public final Builder searchAfter(long value, long... values) { + this.searchAfter = _listAdd(this.searchAfter, FieldValue.of(value)); + for (long v : values) { + _listAdd(this.searchAfter, FieldValue.of(v)); + } + return this; + } + + /** + * The search after definition. + *

    + * API name: {@code search_after} + *

    + * Adds one or more values to searchAfter. + */ + public final Builder searchAfter(double value, double... values) { + this.searchAfter = _listAdd(this.searchAfter, FieldValue.of(value)); + for (double v : values) { + _listAdd(this.searchAfter, FieldValue.of(v)); + } + return this; + } + + /** + * The search after definition. + *

    + * API name: {@code search_after} + *

    + * Adds one or more values to searchAfter. + */ + public final Builder searchAfter(boolean value, boolean... values) { + this.searchAfter = _listAdd(this.searchAfter, FieldValue.of(value)); + for (boolean v : values) { + _listAdd(this.searchAfter, FieldValue.of(v)); + } + return this; + } + + /** + * The search after definition. + *

    + * API name: {@code search_after} + *

    + * Adds a value to searchAfter using a builder lambda. + */ + public final Builder searchAfter(Function> fn) { + return searchAfter(fn.apply(new FieldValue.Builder()).build()); + } + + /** + * The number of hits to return. It must not be negative. By default, you cannot + * page through more than 10,000 hits using the from and + * size parameters. To page through more hits, use the + * search_after parameter. + *

    + * API name: {@code size} + */ + public final Builder size(@Nullable Integer value) { + this.size = value; + return this; + } + + /** + * The sort definition. All the fields that you can query on, other than + * description, are eligible for sorting. In addition, sort can + * also be applied to the _doc field to sort by index order. + *

    + * API name: {@code sort} + *

    + * Adds all elements of list to sort. + */ + public final Builder sort(List list) { + this.sort = _listAddAll(this.sort, list); + return this; + } + + /** + * The sort definition. All the fields that you can query on, other than + * description, are eligible for sorting. In addition, sort can + * also be applied to the _doc field to sort by index order. + *

    + * API name: {@code sort} + *

    + * Adds one or more values to sort. + */ + public final Builder sort(SortOptions value, SortOptions... values) { + this.sort = _listAdd(this.sort, value, values); + return this; + } + + /** + * The sort definition. All the fields that you can query on, other than + * description, are eligible for sorting. In addition, sort can + * also be applied to the _doc field to sort by index order. + *

    + * API name: {@code sort} + *

    + * Adds a value to sort using a builder lambda. + */ + public final Builder sort(Function> fn) { + return sort(fn.apply(new SortOptions.Builder()).build()); + } + + /** + * If true, each service account also includes the profile UIDs of + * the users who created and last replaced it, under the + * created_by_profile_uid and updated_by_profile_uid + * fields. A profile UID is included only for a user who has an activated user + * profile. + *

    + * API name: {@code with_profile_uid} + */ + public final Builder withProfileUid(@Nullable Boolean value) { + this.withProfileUid = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link QueryServiceAccountsRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public QueryServiceAccountsRequest build() { + _checkSingleUse(); + + return new QueryServiceAccountsRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link QueryServiceAccountsRequest} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, QueryServiceAccountsRequest::setupQueryServiceAccountsRequestDeserializer); + + protected static void setupQueryServiceAccountsRequestDeserializer( + ObjectDeserializer op) { + + op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); + op.add(Builder::query, ServiceAccountQuery._DESERIALIZER, "query"); + op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(FieldValue._DESERIALIZER), "search_after"); + op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); + op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code security.query_service_accounts}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/security.query_service_accounts", + + // Request method + request -> { + return "POST"; + + }, + + // Request path + request -> { + return "/_security/_query/service"; + + }, + + // Path parameters + request -> { + return Collections.emptyMap(); + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.withProfileUid != null) { + params.put("with_profile_uid", String.valueOf(request.withProfileUid)); + } + return params; + + }, SimpleEndpoint.emptyMap(), true, QueryServiceAccountsResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/QueryServiceAccountsResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/QueryServiceAccountsResponse.java new file mode 100644 index 0000000000..e4d3642eb2 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/QueryServiceAccountsResponse.java @@ -0,0 +1,254 @@ +/* + * 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.security; + +import co.elastic.clients.elasticsearch.security.query_service_accounts.QueryServiceAccount; +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.JsonpUtils; +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.util.List; +import java.util.Objects; +import java.util.function.Function; +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: security.query_service_accounts.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class QueryServiceAccountsResponse implements JsonpSerializable { + private final int total; + + private final int count; + + private final List serviceAccounts; + + // --------------------------------------------------------------------------------------------- + + private QueryServiceAccountsResponse(Builder builder) { + + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total", 0); + this.count = ApiTypeHelper.requireNonNull(builder.count, this, "count", 0); + this.serviceAccounts = ApiTypeHelper.unmodifiableRequired(builder.serviceAccounts, this, "serviceAccounts"); + + } + + public static QueryServiceAccountsResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The total number of service accounts found. + *

    + * API name: {@code total} + */ + public final int total() { + return this.total; + } + + /** + * Required - The number of service accounts returned in the response. + *

    + * API name: {@code count} + */ + public final int count() { + return this.count; + } + + /** + * Required - A list of service account information. + *

    + * API name: {@code service_accounts} + */ + public final List serviceAccounts() { + return this.serviceAccounts; + } + + /** + * 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("total"); + generator.write(this.total); + + generator.writeKey("count"); + generator.write(this.count); + + if (ApiTypeHelper.isDefined(this.serviceAccounts)) { + generator.writeKey("service_accounts"); + generator.writeStartArray(); + for (QueryServiceAccount item0 : this.serviceAccounts) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link QueryServiceAccountsResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Integer total; + + private Integer count; + + private List serviceAccounts; + + /** + * Required - The total number of service accounts found. + *

    + * API name: {@code total} + */ + public final Builder total(int value) { + this.total = value; + return this; + } + + /** + * Required - The number of service accounts returned in the response. + *

    + * API name: {@code count} + */ + public final Builder count(int value) { + this.count = value; + return this; + } + + /** + * Required - A list of service account information. + *

    + * API name: {@code service_accounts} + *

    + * Adds all elements of list to serviceAccounts. + */ + public final Builder serviceAccounts(List list) { + this.serviceAccounts = _listAddAll(this.serviceAccounts, list); + return this; + } + + /** + * Required - A list of service account information. + *

    + * API name: {@code service_accounts} + *

    + * Adds one or more values to serviceAccounts. + */ + public final Builder serviceAccounts(QueryServiceAccount value, QueryServiceAccount... values) { + this.serviceAccounts = _listAdd(this.serviceAccounts, value, values); + return this; + } + + /** + * Required - A list of service account information. + *

    + * API name: {@code service_accounts} + *

    + * Adds a value to serviceAccounts using a builder lambda. + */ + public final Builder serviceAccounts( + Function> fn) { + return serviceAccounts(fn.apply(new QueryServiceAccount.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link QueryServiceAccountsResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public QueryServiceAccountsResponse build() { + _checkSingleUse(); + + return new QueryServiceAccountsResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link QueryServiceAccountsResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, QueryServiceAccountsResponse::setupQueryServiceAccountsResponseDeserializer); + + protected static void setupQueryServiceAccountsResponseDeserializer( + ObjectDeserializer op) { + + op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); + op.add(Builder::count, JsonpDeserializer.integerDeserializer(), "count"); + op.add(Builder::serviceAccounts, JsonpDeserializer.arrayDeserializer(QueryServiceAccount._DESERIALIZER), + "service_accounts"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/WriteProfileGlobalUserPrivileges.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/WriteProfileGlobalUserPrivileges.java new file mode 100644 index 0000000000..3a06d36fd8 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/WriteProfileGlobalUserPrivileges.java @@ -0,0 +1,190 @@ +/* + * 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.security; + +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.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +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: security._types.WriteProfileGlobalUserPrivileges + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class WriteProfileGlobalUserPrivileges implements JsonpSerializable { + @Nullable + private final ManageUserPrivileges write; + + // --------------------------------------------------------------------------------------------- + + private WriteProfileGlobalUserPrivileges(Builder builder) { + + this.write = builder.write; + + } + + public static WriteProfileGlobalUserPrivileges of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The applications for which user profile data can be written. Absent when the + * profile section is present but grants no privileges. + *

    + * API name: {@code write} + */ + @Nullable + public final ManageUserPrivileges write() { + return this.write; + } + + /** + * 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 (this.write != null) { + generator.writeKey("write"); + this.write.serialize(generator, mapper); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link WriteProfileGlobalUserPrivileges}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private ManageUserPrivileges write; + + public Builder() { + } + private Builder(WriteProfileGlobalUserPrivileges instance) { + this.write = instance.write; + + } + /** + * The applications for which user profile data can be written. Absent when the + * profile section is present but grants no privileges. + *

    + * API name: {@code write} + */ + public final Builder write(@Nullable ManageUserPrivileges value) { + this.write = value; + return this; + } + + /** + * The applications for which user profile data can be written. Absent when the + * profile section is present but grants no privileges. + *

    + * API name: {@code write} + */ + public final Builder write(Function> fn) { + return this.write(fn.apply(new ManageUserPrivileges.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link WriteProfileGlobalUserPrivileges}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public WriteProfileGlobalUserPrivileges build() { + _checkSingleUse(); + + return new WriteProfileGlobalUserPrivileges(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link WriteProfileGlobalUserPrivileges} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, WriteProfileGlobalUserPrivileges::setupWriteProfileGlobalUserPrivilegesDeserializer); + + protected static void setupWriteProfileGlobalUserPrivilegesDeserializer( + ObjectDeserializer op) { + + op.add(Builder::write, ManageUserPrivileges._DESERIALIZER, "write"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_role/Role.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_role/Role.java index a0b0ba5d5c..8cfaa0ce13 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_role/Role.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_role/Role.java @@ -21,6 +21,7 @@ import co.elastic.clients.elasticsearch.security.ApplicationPrivileges; import co.elastic.clients.elasticsearch.security.ClusterPrivilege; +import co.elastic.clients.elasticsearch.security.GlobalPrivilege; import co.elastic.clients.elasticsearch.security.RemoteClusterPrivileges; import co.elastic.clients.elasticsearch.security.RemoteIndicesPrivileges; import co.elastic.clients.elasticsearch.security.RoleTemplate; @@ -89,7 +90,8 @@ public class Role implements JsonpSerializable { private final List roleTemplates; - private final Map>>> global; + @Nullable + private final GlobalPrivilege global; // --------------------------------------------------------------------------------------------- @@ -105,7 +107,7 @@ private Role(Builder builder) { this.transientMetadata = ApiTypeHelper.unmodifiable(builder.transientMetadata); this.applications = ApiTypeHelper.unmodifiableRequired(builder.applications, this, "applications"); this.roleTemplates = ApiTypeHelper.unmodifiable(builder.roleTemplates); - this.global = ApiTypeHelper.unmodifiable(builder.global); + this.global = builder.global; } @@ -187,7 +189,8 @@ public final List roleTemplates() { /** * API name: {@code global} */ - public final Map>>> global() { + @Nullable + public final GlobalPrivilege global() { return this.global; } @@ -299,38 +302,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } - if (ApiTypeHelper.isDefined(this.global)) { + if (this.global != null) { generator.writeKey("global"); - generator.writeStartObject(); - for (Map.Entry>>> item0 : this.global.entrySet()) { - generator.writeKey(item0.getKey()); - generator.writeStartObject(); - if (item0.getValue() != null) { - for (Map.Entry>> item1 : item0.getValue().entrySet()) { - generator.writeKey(item1.getKey()); - generator.writeStartObject(); - if (item1.getValue() != null) { - for (Map.Entry> item2 : item1.getValue().entrySet()) { - generator.writeKey(item2.getKey()); - generator.writeStartArray(); - if (item2.getValue() != null) { - for (String item3 : item2.getValue()) { - generator.write(item3); - - } - } - generator.writeEnd(); - - } - } - generator.writeEnd(); - - } - } - generator.writeEnd(); - - } - generator.writeEnd(); + this.global.serialize(generator, mapper); } @@ -375,7 +349,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private List roleTemplates; @Nullable - private Map>>> global; + private GlobalPrivilege global; public Builder() { } @@ -642,22 +616,17 @@ public final Builder roleTemplates(Function - * Adds all entries of map to global. */ - public final Builder global(Map>>> map) { - this.global = _mapPutAll(this.global, map); + public final Builder global(@Nullable GlobalPrivilege value) { + this.global = value; return this; } /** * API name: {@code global} - *

    - * Adds an entry to global. */ - public final Builder global(String key, Map>> value) { - this.global = _mapPut(this.global, key, value); - return this; + public final Builder global(Function> fn) { + return this.global(fn.apply(new GlobalPrivilege.Builder()).build()); } @Override @@ -710,11 +679,7 @@ protected static void setupRoleDeserializer(ObjectDeserializer op) "applications"); op.add(Builder::roleTemplates, JsonpDeserializer.arrayDeserializer(RoleTemplate._DESERIALIZER), "role_templates"); - op.add(Builder::global, - JsonpDeserializer.stringMapDeserializer( - JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringMapDeserializer( - JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer())))), - "global"); + op.add(Builder::global, GlobalPrivilege._DESERIALIZER, "global"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountAuthor.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountAuthor.java new file mode 100644 index 0000000000..22d53f734d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountAuthor.java @@ -0,0 +1,283 @@ +/* + * 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.security.get_service_accounts; + +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: security.get_service_accounts.ServiceAccountAuthor + +/** + * The user who wrote a user-managed service account. If the request ran as + * another user, that user is recorded. If the request was made with an API key, + * the owner of the key is recorded, from the owner's own realm, together with + * the key itself. For an older API key that does not record its owner's realm, + * the realm is the API key realm, _es_api_key. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ServiceAccountAuthor implements JsonpSerializable { + private final String username; + + private final String realm; + + private final String realmType; + + @Nullable + private final ServiceAccountAuthorApiKey apiKey; + + // --------------------------------------------------------------------------------------------- + + private ServiceAccountAuthor(Builder builder) { + + this.username = ApiTypeHelper.requireNonNull(builder.username, this, "username"); + this.realm = ApiTypeHelper.requireNonNull(builder.realm, this, "realm"); + this.realmType = ApiTypeHelper.requireNonNull(builder.realmType, this, "realmType"); + this.apiKey = builder.apiKey; + + } + + public static ServiceAccountAuthor of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The username of the user. + *

    + * API name: {@code username} + */ + public final String username() { + return this.username; + } + + /** + * Required - The name of the realm that authenticated the user. + *

    + * API name: {@code realm} + */ + public final String realm() { + return this.realm; + } + + /** + * Required - The type of the realm that authenticated the user. + *

    + * API name: {@code realm_type} + */ + public final String realmType() { + return this.realmType; + } + + /** + * The API key that the request was made with. Absent when the request was not + * made with an API key, or when the API key ran as another user. + *

    + * API name: {@code api_key} + */ + @Nullable + public final ServiceAccountAuthorApiKey apiKey() { + return this.apiKey; + } + + /** + * 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("username"); + generator.write(this.username); + + generator.writeKey("realm"); + generator.write(this.realm); + + generator.writeKey("realm_type"); + generator.write(this.realmType); + + if (this.apiKey != null) { + generator.writeKey("api_key"); + this.apiKey.serialize(generator, mapper); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ServiceAccountAuthor}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String username; + + private String realm; + + private String realmType; + + @Nullable + private ServiceAccountAuthorApiKey apiKey; + + public Builder() { + } + private Builder(ServiceAccountAuthor instance) { + this.username = instance.username; + this.realm = instance.realm; + this.realmType = instance.realmType; + this.apiKey = instance.apiKey; + + } + /** + * Required - The username of the user. + *

    + * API name: {@code username} + */ + public final Builder username(String value) { + this.username = value; + return this; + } + + /** + * Required - The name of the realm that authenticated the user. + *

    + * API name: {@code realm} + */ + public final Builder realm(String value) { + this.realm = value; + return this; + } + + /** + * Required - The type of the realm that authenticated the user. + *

    + * API name: {@code realm_type} + */ + public final Builder realmType(String value) { + this.realmType = value; + return this; + } + + /** + * The API key that the request was made with. Absent when the request was not + * made with an API key, or when the API key ran as another user. + *

    + * API name: {@code api_key} + */ + public final Builder apiKey(@Nullable ServiceAccountAuthorApiKey value) { + this.apiKey = value; + return this; + } + + /** + * The API key that the request was made with. Absent when the request was not + * made with an API key, or when the API key ran as another user. + *

    + * API name: {@code api_key} + */ + public final Builder apiKey( + Function> fn) { + return this.apiKey(fn.apply(new ServiceAccountAuthorApiKey.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ServiceAccountAuthor}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ServiceAccountAuthor build() { + _checkSingleUse(); + + return new ServiceAccountAuthor(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ServiceAccountAuthor} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ServiceAccountAuthor::setupServiceAccountAuthorDeserializer); + + protected static void setupServiceAccountAuthorDeserializer(ObjectDeserializer op) { + + op.add(Builder::username, JsonpDeserializer.stringDeserializer(), "username"); + op.add(Builder::realm, JsonpDeserializer.stringDeserializer(), "realm"); + op.add(Builder::realmType, JsonpDeserializer.stringDeserializer(), "realm_type"); + op.add(Builder::apiKey, ServiceAccountAuthorApiKey._DESERIALIZER, "api_key"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountAuthorApiKey.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountAuthorApiKey.java new file mode 100644 index 0000000000..4930a4cd44 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountAuthorApiKey.java @@ -0,0 +1,210 @@ +/* + * 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.security.get_service_accounts; + +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: security.get_service_accounts.ServiceAccountAuthorApiKey + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ServiceAccountAuthorApiKey implements JsonpSerializable { + private final String id; + + @Nullable + private final String name; + + // --------------------------------------------------------------------------------------------- + + private ServiceAccountAuthorApiKey(Builder builder) { + + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.name = builder.name; + + } + + public static ServiceAccountAuthorApiKey of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The ID of the API key. + *

    + * API name: {@code id} + */ + public final String id() { + return this.id; + } + + /** + * The name that the API key had when the request was made. Absent when the API + * key has no name. + *

    + * API name: {@code name} + */ + @Nullable + public final String name() { + return this.name; + } + + /** + * 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("id"); + generator.write(this.id); + + if (this.name != null) { + generator.writeKey("name"); + generator.write(this.name); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ServiceAccountAuthorApiKey}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String id; + + @Nullable + private String name; + + public Builder() { + } + private Builder(ServiceAccountAuthorApiKey instance) { + this.id = instance.id; + this.name = instance.name; + + } + /** + * Required - The ID of the API key. + *

    + * API name: {@code id} + */ + public final Builder id(String value) { + this.id = value; + return this; + } + + /** + * The name that the API key had when the request was made. Absent when the API + * key has no name. + *

    + * API name: {@code name} + */ + public final Builder name(@Nullable String value) { + this.name = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ServiceAccountAuthorApiKey}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ServiceAccountAuthorApiKey build() { + _checkSingleUse(); + + return new ServiceAccountAuthorApiKey(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ServiceAccountAuthorApiKey} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ServiceAccountAuthorApiKey::setupServiceAccountAuthorApiKeyDeserializer); + + protected static void setupServiceAccountAuthorApiKeyDeserializer( + ObjectDeserializer op) { + + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/UserManagedServiceAccount.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/UserManagedServiceAccount.java index 6feaad433f..2c7d2ee632 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/UserManagedServiceAccount.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/UserManagedServiceAccount.java @@ -31,6 +31,7 @@ import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; +import java.lang.Long; import java.lang.String; import java.util.List; import java.util.Objects; @@ -66,16 +67,45 @@ public class UserManagedServiceAccount implements ServiceAccountInfoVariant, Jso private final boolean enabled; + @Nullable + private final String description; + + @Nullable + private final ServiceAccountAuthor createdBy; + + @Nullable + private final Long createdAt; + + @Nullable + private final String createdByProfileUid; + + @Nullable + private final ServiceAccountAuthor updatedBy; + + @Nullable + private final Long updatedAt; + + @Nullable + private final String updatedByProfileUid; + // --------------------------------------------------------------------------------------------- - private UserManagedServiceAccount(Builder builder) { + protected UserManagedServiceAccount(AbstractBuilder builder) { this.roles = ApiTypeHelper.unmodifiableRequired(builder.roles, this, "roles"); this.enabled = ApiTypeHelper.requireNonNull(builder.enabled, this, "enabled", false); + this.description = builder.description; + this.createdBy = builder.createdBy; + this.createdAt = builder.createdAt; + this.createdByProfileUid = builder.createdByProfileUid; + this.updatedBy = builder.updatedBy; + this.updatedAt = builder.updatedAt; + this.updatedByProfileUid = builder.updatedByProfileUid; } - public static UserManagedServiceAccount of(Function> fn) { + public static UserManagedServiceAccount userManagedServiceAccountOf( + Function> fn) { return fn.apply(new Builder()).build(); } @@ -88,8 +118,8 @@ public ServiceAccountInfo.Kind _serviceAccountInfoKind() { } /** - * Required - The names of the roles granted to the account, as they were given - * when it was created. They are resolved when the account authenticates. + * Required - The names of the roles granted to the account, as sent on the last + * PUT of the account. They are resolved when the account authenticates. *

    * API name: {@code roles} */ @@ -106,6 +136,87 @@ public final boolean enabled() { return this.enabled; } + /** + * A free-text description of the account, as sent on the last PUT of the + * account. It has no meaning to Elasticsearch. Absent when the account has no + * description. + *

    + * API name: {@code description} + */ + @Nullable + public final String description() { + return this.description; + } + + /** + * The user who created the account. Absent for an account that was created + * before Elasticsearch recorded its creator. + *

    + * API name: {@code created_by} + */ + @Nullable + public final ServiceAccountAuthor createdBy() { + return this.createdBy; + } + + /** + * When the account was created, in milliseconds since the Unix epoch. Absent + * for an account that was created before Elasticsearch recorded its creation + * time. + *

    + * API name: {@code created_at} + */ + @Nullable + public final Long createdAt() { + return this.createdAt; + } + + /** + * The profile UID of the user who created the account. Returned only when + * with_profile_uid is true and that user has an + * activated user profile. + *

    + * API name: {@code created_by_profile_uid} + */ + @Nullable + public final String createdByProfileUid() { + return this.createdByProfileUid; + } + + /** + * The user who last replaced the account with the put user-managed service + * account API. Absent until the account is first replaced. + *

    + * API name: {@code updated_by} + */ + @Nullable + public final ServiceAccountAuthor updatedBy() { + return this.updatedBy; + } + + /** + * When the account was last replaced, in milliseconds since the Unix epoch. + * Absent until the account is first replaced. + *

    + * API name: {@code updated_at} + */ + @Nullable + public final Long updatedAt() { + return this.updatedAt; + } + + /** + * The profile UID of the user who last replaced the account. Returned only when + * with_profile_uid is true and that user has an + * activated user profile. + *

    + * API name: {@code updated_by_profile_uid} + */ + @Nullable + public final String updatedByProfileUid() { + return this.updatedByProfileUid; + } + /** * Serialize this object to JSON. */ @@ -132,6 +243,42 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("enabled"); generator.write(this.enabled); + if (this.description != null) { + generator.writeKey("description"); + generator.write(this.description); + + } + if (this.createdBy != null) { + generator.writeKey("created_by"); + this.createdBy.serialize(generator, mapper); + + } + if (this.createdAt != null) { + generator.writeKey("created_at"); + generator.write(this.createdAt); + + } + if (this.createdByProfileUid != null) { + generator.writeKey("created_by_profile_uid"); + generator.write(this.createdByProfileUid); + + } + if (this.updatedBy != null) { + generator.writeKey("updated_by"); + this.updatedBy.serialize(generator, mapper); + + } + if (this.updatedAt != null) { + generator.writeKey("updated_at"); + generator.write(this.updatedAt); + + } + if (this.updatedByProfileUid != null) { + generator.writeKey("updated_by_profile_uid"); + generator.write(this.updatedByProfileUid); + + } + } @Override @@ -145,44 +292,79 @@ public String toString() { * Builder for {@link UserManagedServiceAccount}. */ - public static class Builder extends WithJsonObjectBuilderBase + public static class Builder extends UserManagedServiceAccount.AbstractBuilder implements ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link UserManagedServiceAccount}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public UserManagedServiceAccount build() { + _checkSingleUse(); + + return new UserManagedServiceAccount(this); + } + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { private List roles; private Boolean enabled; - public Builder() { - } - private Builder(UserManagedServiceAccount instance) { - this.roles = instance.roles; - this.enabled = instance.enabled; + @Nullable + private String description; + + @Nullable + private ServiceAccountAuthor createdBy; + + @Nullable + private Long createdAt; + + @Nullable + private String createdByProfileUid; + + @Nullable + private ServiceAccountAuthor updatedBy; + + @Nullable + private Long updatedAt; + + @Nullable + private String updatedByProfileUid; - } /** - * Required - The names of the roles granted to the account, as they were given - * when it was created. They are resolved when the account authenticates. + * Required - The names of the roles granted to the account, as sent on the last + * PUT of the account. They are resolved when the account authenticates. *

    * API name: {@code roles} *

    * Adds all elements of list to roles. */ - public final Builder roles(List list) { + public final BuilderT roles(List list) { this.roles = _listAddAll(this.roles, list); - return this; + return self(); } /** - * Required - The names of the roles granted to the account, as they were given - * when it was created. They are resolved when the account authenticates. + * Required - The names of the roles granted to the account, as sent on the last + * PUT of the account. They are resolved when the account authenticates. *

    * API name: {@code roles} *

    * Adds one or more values to roles. */ - public final Builder roles(String value, String... values) { + public final BuilderT roles(String value, String... values) { this.roles = _listAdd(this.roles, value, values); - return this; + return self(); } /** @@ -190,35 +372,118 @@ public final Builder roles(String value, String... values) { *

    * API name: {@code enabled} */ - public final Builder enabled(boolean value) { + public final BuilderT enabled(boolean value) { this.enabled = value; - return this; + return self(); } - @Override - protected Builder self() { - return this; + /** + * A free-text description of the account, as sent on the last PUT of the + * account. It has no meaning to Elasticsearch. Absent when the account has no + * description. + *

    + * API name: {@code description} + */ + public final BuilderT description(@Nullable String value) { + this.description = value; + return self(); } /** - * Builds a {@link UserManagedServiceAccount}. - * - * @throws NullPointerException - * if some of the required fields are null. + * The user who created the account. Absent for an account that was created + * before Elasticsearch recorded its creator. + *

    + * API name: {@code created_by} */ - public UserManagedServiceAccount build() { - _checkSingleUse(); + public final BuilderT createdBy(@Nullable ServiceAccountAuthor value) { + this.createdBy = value; + return self(); + } - return new UserManagedServiceAccount(this); + /** + * The user who created the account. Absent for an account that was created + * before Elasticsearch recorded its creator. + *

    + * API name: {@code created_by} + */ + public final BuilderT createdBy( + Function> fn) { + return this.createdBy(fn.apply(new ServiceAccountAuthor.Builder()).build()); } - } - /** - * @return New {@link Builder} initialized with field values of this instance - */ - public Builder rebuild() { - return new Builder(this); + /** + * When the account was created, in milliseconds since the Unix epoch. Absent + * for an account that was created before Elasticsearch recorded its creation + * time. + *

    + * API name: {@code created_at} + */ + public final BuilderT createdAt(@Nullable Long value) { + this.createdAt = value; + return self(); + } + + /** + * The profile UID of the user who created the account. Returned only when + * with_profile_uid is true and that user has an + * activated user profile. + *

    + * API name: {@code created_by_profile_uid} + */ + public final BuilderT createdByProfileUid(@Nullable String value) { + this.createdByProfileUid = value; + return self(); + } + + /** + * The user who last replaced the account with the put user-managed service + * account API. Absent until the account is first replaced. + *

    + * API name: {@code updated_by} + */ + public final BuilderT updatedBy(@Nullable ServiceAccountAuthor value) { + this.updatedBy = value; + return self(); + } + + /** + * The user who last replaced the account with the put user-managed service + * account API. Absent until the account is first replaced. + *

    + * API name: {@code updated_by} + */ + public final BuilderT updatedBy( + Function> fn) { + return this.updatedBy(fn.apply(new ServiceAccountAuthor.Builder()).build()); + } + + /** + * When the account was last replaced, in milliseconds since the Unix epoch. + * Absent until the account is first replaced. + *

    + * API name: {@code updated_at} + */ + public final BuilderT updatedAt(@Nullable Long value) { + this.updatedAt = value; + return self(); + } + + /** + * The profile UID of the user who last replaced the account. Returned only when + * with_profile_uid is true and that user has an + * activated user profile. + *

    + * API name: {@code updated_by_profile_uid} + */ + public final BuilderT updatedByProfileUid(@Nullable String value) { + this.updatedByProfileUid = value; + return self(); + } + + protected abstract BuilderT self(); + } + // --------------------------------------------------------------------------------------------- /** @@ -227,11 +492,19 @@ public Builder rebuild() { public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer .lazy(Builder::new, UserManagedServiceAccount::setupUserManagedServiceAccountDeserializer); - protected static void setupUserManagedServiceAccountDeserializer( - ObjectDeserializer op) { - - op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "roles"); - op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + protected static > void setupUserManagedServiceAccountDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::roles, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "roles"); + op.add(AbstractBuilder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + op.add(AbstractBuilder::description, JsonpDeserializer.stringDeserializer(), "description"); + op.add(AbstractBuilder::createdBy, ServiceAccountAuthor._DESERIALIZER, "created_by"); + op.add(AbstractBuilder::createdAt, JsonpDeserializer.longDeserializer(), "created_at"); + op.add(AbstractBuilder::createdByProfileUid, JsonpDeserializer.stringDeserializer(), "created_by_profile_uid"); + op.add(AbstractBuilder::updatedBy, ServiceAccountAuthor._DESERIALIZER, "updated_by"); + op.add(AbstractBuilder::updatedAt, JsonpDeserializer.longDeserializer(), "updated_at"); + op.add(AbstractBuilder::updatedByProfileUid, JsonpDeserializer.stringDeserializer(), "updated_by_profile_uid"); op.ignore("type"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_token/AuthenticatedUser.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_token/AuthenticatedUser.java index 8475580320..9e51bafd07 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_token/AuthenticatedUser.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_token/AuthenticatedUser.java @@ -20,6 +20,8 @@ package co.elastic.clients.elasticsearch.security.get_token; import co.elastic.clients.elasticsearch.security.User; +import co.elastic.clients.elasticsearch.security.authenticate.AuthenticateApiKey; +import co.elastic.clients.elasticsearch.security.authenticate.ServiceToken; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -67,6 +69,12 @@ public class AuthenticatedUser extends User { private final String authenticationType; + @Nullable + private final AuthenticateApiKey apiKey; + + @Nullable + private final ServiceToken token; + // --------------------------------------------------------------------------------------------- private AuthenticatedUser(Builder builder) { @@ -77,6 +85,8 @@ private AuthenticatedUser(Builder builder) { this.lookupRealm = ApiTypeHelper.requireNonNull(builder.lookupRealm, this, "lookupRealm"); this.authenticationProvider = builder.authenticationProvider; this.authenticationType = ApiTypeHelper.requireNonNull(builder.authenticationType, this, "authenticationType"); + this.apiKey = builder.apiKey; + this.token = builder.token; } @@ -113,6 +123,27 @@ public final String authenticationType() { return this.authenticationType; } + /** + * Present when the authenticated user is an API key. + *

    + * API name: {@code api_key} + */ + @Nullable + public final AuthenticateApiKey apiKey() { + return this.apiKey; + } + + /** + * Present when the authenticated user is a service account, or authenticated + * with a token. + *

    + * API name: {@code token} + */ + @Nullable + public final ServiceToken token() { + return this.token; + } + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { super.serializeInternal(generator, mapper); @@ -130,6 +161,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("authentication_type"); generator.write(this.authenticationType); + if (this.apiKey != null) { + generator.writeKey("api_key"); + this.apiKey.serialize(generator, mapper); + + } + if (this.token != null) { + generator.writeKey("token"); + this.token.serialize(generator, mapper); + + } + } // --------------------------------------------------------------------------------------------- @@ -148,6 +190,12 @@ public static class Builder extends User.AbstractBuilder implements Obj private String authenticationType; + @Nullable + private AuthenticateApiKey apiKey; + + @Nullable + private ServiceToken token; + public Builder() { } private Builder(AuthenticatedUser instance) { @@ -155,6 +203,8 @@ private Builder(AuthenticatedUser instance) { this.lookupRealm = instance.lookupRealm; this.authenticationProvider = instance.authenticationProvider; this.authenticationType = instance.authenticationType; + this.apiKey = instance.apiKey; + this.token = instance.token; } /** @@ -211,6 +261,46 @@ public final Builder authenticationType(String value) { return this; } + /** + * Present when the authenticated user is an API key. + *

    + * API name: {@code api_key} + */ + public final Builder apiKey(@Nullable AuthenticateApiKey value) { + this.apiKey = value; + return this; + } + + /** + * Present when the authenticated user is an API key. + *

    + * API name: {@code api_key} + */ + public final Builder apiKey(Function> fn) { + return this.apiKey(fn.apply(new AuthenticateApiKey.Builder()).build()); + } + + /** + * Present when the authenticated user is a service account, or authenticated + * with a token. + *

    + * API name: {@code token} + */ + public final Builder token(@Nullable ServiceToken value) { + this.token = value; + return this; + } + + /** + * Present when the authenticated user is a service account, or authenticated + * with a token. + *

    + * API name: {@code token} + */ + public final Builder token(Function> fn) { + return this.token(fn.apply(new ServiceToken.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -249,6 +339,8 @@ protected static void setupAuthenticatedUserDeserializer(ObjectDeserializerservice_account_token + * parameter. The API key is owned by the service account and is limited by the + * roles assigned to it. The service account token is authenticated on every + * grant, so a disabled account or an invalidated token is rejected. Tokens that + * belong to built-in (elastic/*) service accounts are rejected. + */ + UserManagedServiceAccount("_user_managed_service_account"), + ; private final String jsonValue; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/grant_api_key/GrantApiKeyClientAuthentication.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/grant_api_key/GrantApiKeyClientAuthentication.java new file mode 100644 index 0000000000..aeb1c84d02 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/grant_api_key/GrantApiKeyClientAuthentication.java @@ -0,0 +1,204 @@ +/* + * 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.security.grant_api_key; + +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.JsonpUtils; +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.String; +import java.util.Objects; +import java.util.function.Function; +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: security.grant_api_key.GrantApiKeyClientAuthentication + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class GrantApiKeyClientAuthentication implements JsonpSerializable { + private final GrantApiKeyClientAuthenticationScheme scheme; + + private final String value; + + // --------------------------------------------------------------------------------------------- + + private GrantApiKeyClientAuthentication(Builder builder) { + + this.scheme = ApiTypeHelper.requireNonNull(builder.scheme, this, "scheme"); + this.value = ApiTypeHelper.requireNonNull(builder.value, this, "value"); + + } + + public static GrantApiKeyClientAuthentication of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The client authentication scheme. + *

    + * API name: {@code scheme} + */ + public final GrantApiKeyClientAuthenticationScheme scheme() { + return this.scheme; + } + + /** + * Required - The client authentication value, which is what normally follows + * the scheme in the ES-Client-Authentication request header. + *

    + * API name: {@code value} + */ + public final String value() { + return this.value; + } + + /** + * 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("scheme"); + this.scheme.serialize(generator, mapper); + generator.writeKey("value"); + generator.write(this.value); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GrantApiKeyClientAuthentication}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private GrantApiKeyClientAuthenticationScheme scheme; + + private String value; + + public Builder() { + } + private Builder(GrantApiKeyClientAuthentication instance) { + this.scheme = instance.scheme; + this.value = instance.value; + + } + /** + * Required - The client authentication scheme. + *

    + * API name: {@code scheme} + */ + public final Builder scheme(GrantApiKeyClientAuthenticationScheme value) { + this.scheme = value; + return this; + } + + /** + * Required - The client authentication value, which is what normally follows + * the scheme in the ES-Client-Authentication request header. + *

    + * API name: {@code value} + */ + public final Builder value(String value) { + this.value = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GrantApiKeyClientAuthentication}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GrantApiKeyClientAuthentication build() { + _checkSingleUse(); + + return new GrantApiKeyClientAuthentication(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GrantApiKeyClientAuthentication} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, GrantApiKeyClientAuthentication::setupGrantApiKeyClientAuthenticationDeserializer); + + protected static void setupGrantApiKeyClientAuthenticationDeserializer( + ObjectDeserializer op) { + + op.add(Builder::scheme, GrantApiKeyClientAuthenticationScheme._DESERIALIZER, "scheme"); + op.add(Builder::value, JsonpDeserializer.stringDeserializer(), "value"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/grant_api_key/GrantApiKeyClientAuthenticationScheme.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/grant_api_key/GrantApiKeyClientAuthenticationScheme.java new file mode 100644 index 0000000000..08320c35a2 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/grant_api_key/GrantApiKeyClientAuthenticationScheme.java @@ -0,0 +1,68 @@ +/* + * 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.security.grant_api_key; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum GrantApiKeyClientAuthenticationScheme implements JsonEnum { + /** + * The client authenticates with the shared secret configured for the JWT realm. + */ + SharedSecret("SharedSecret"), + + ; + + private final String jsonValue; + + GrantApiKeyClientAuthenticationScheme(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + GrantApiKeyClientAuthenticationScheme.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/QueryServiceAccount.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/QueryServiceAccount.java new file mode 100644 index 0000000000..7948131bb8 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/QueryServiceAccount.java @@ -0,0 +1,293 @@ +/* + * 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.security.query_service_accounts; + +import co.elastic.clients.elasticsearch._types.FieldValue; +import co.elastic.clients.elasticsearch.security.get_service_accounts.UserManagedServiceAccount; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +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 jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +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: security.query_service_accounts.QueryServiceAccount + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class QueryServiceAccount extends UserManagedServiceAccount { + private final String username; + + private final List sort; + + // --------------------------------------------------------------------------------------------- + + private QueryServiceAccount(Builder builder) { + super(builder); + + this.username = ApiTypeHelper.requireNonNull(builder.username, this, "username"); + this.sort = ApiTypeHelper.unmodifiable(builder.sort); + + } + + public static QueryServiceAccount of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The name of the service account, as + * namespace/service. + *

    + * API name: {@code username} + */ + public final String username() { + return this.username; + } + + /** + * The sort values of the service account, returned when the request has a + * sort. + *

    + * API name: {@code _sort} + */ + public final List sort() { + return this.sort; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + generator.writeKey("username"); + generator.write(this.username); + + if (ApiTypeHelper.isDefined(this.sort)) { + generator.writeKey("_sort"); + generator.writeStartArray(); + for (FieldValue item0 : this.sort) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link QueryServiceAccount}. + */ + + public static class Builder extends UserManagedServiceAccount.AbstractBuilder + implements + ObjectBuilder { + private String username; + + @Nullable + private List sort; + + public Builder() { + } + private Builder(QueryServiceAccount instance) { + this.username = instance.username; + this.sort = instance.sort; + + } + /** + * Required - The name of the service account, as + * namespace/service. + *

    + * API name: {@code username} + */ + public final Builder username(String value) { + this.username = value; + return this; + } + + /** + * The sort values of the service account, returned when the request has a + * sort. + *

    + * API name: {@code _sort} + *

    + * Adds all elements of list to sort. + */ + public final Builder sort(List list) { + this.sort = _listAddAll(this.sort, list); + return this; + } + + /** + * The sort values of the service account, returned when the request has a + * sort. + *

    + * API name: {@code _sort} + *

    + * Adds one or more values to sort. + */ + public final Builder sort(FieldValue value, FieldValue... values) { + this.sort = _listAdd(this.sort, value, values); + return this; + } + + /** + * The sort values of the service account, returned when the request has a + * sort. + *

    + * API name: {@code _sort} + *

    + * Adds one or more values to sort. + */ + public final Builder sort(String value, String... values) { + this.sort = _listAdd(this.sort, FieldValue.of(value)); + for (String v : values) { + _listAdd(this.sort, FieldValue.of(v)); + } + return this; + } + + /** + * The sort values of the service account, returned when the request has a + * sort. + *

    + * API name: {@code _sort} + *

    + * Adds one or more values to sort. + */ + public final Builder sort(long value, long... values) { + this.sort = _listAdd(this.sort, FieldValue.of(value)); + for (long v : values) { + _listAdd(this.sort, FieldValue.of(v)); + } + return this; + } + + /** + * The sort values of the service account, returned when the request has a + * sort. + *

    + * API name: {@code _sort} + *

    + * Adds one or more values to sort. + */ + public final Builder sort(double value, double... values) { + this.sort = _listAdd(this.sort, FieldValue.of(value)); + for (double v : values) { + _listAdd(this.sort, FieldValue.of(v)); + } + return this; + } + + /** + * The sort values of the service account, returned when the request has a + * sort. + *

    + * API name: {@code _sort} + *

    + * Adds one or more values to sort. + */ + public final Builder sort(boolean value, boolean... values) { + this.sort = _listAdd(this.sort, FieldValue.of(value)); + for (boolean v : values) { + _listAdd(this.sort, FieldValue.of(v)); + } + return this; + } + + /** + * The sort values of the service account, returned when the request has a + * sort. + *

    + * API name: {@code _sort} + *

    + * Adds a value to sort using a builder lambda. + */ + public final Builder sort(Function> fn) { + return sort(fn.apply(new FieldValue.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link QueryServiceAccount}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public QueryServiceAccount build() { + _checkSingleUse(); + + return new QueryServiceAccount(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link QueryServiceAccount} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, QueryServiceAccount::setupQueryServiceAccountDeserializer); + + protected static void setupQueryServiceAccountDeserializer(ObjectDeserializer op) { + UserManagedServiceAccount.setupUserManagedServiceAccountDeserializer(op); + op.add(Builder::username, JsonpDeserializer.stringDeserializer(), "username"); + op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(FieldValue._DESERIALIZER), "_sort"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/ServiceAccountQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/ServiceAccountQuery.java new file mode 100644 index 0000000000..b2ea7683a4 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/ServiceAccountQuery.java @@ -0,0 +1,586 @@ +/* + * 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.security.query_service_accounts; + +import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.ExistsQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.IdsQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.MatchAllQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.MatchQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.PrefixQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.RangeQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.SimpleQueryStringQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.TermQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.TermsQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.WildcardQuery; +import co.elastic.clients.json.JsonData; +import co.elastic.clients.json.JsonEnum; +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.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.NamedValue; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.OpenTaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Object; +import java.util.Objects; +import java.util.function.Function; +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: security.query_service_accounts.ServiceAccountQueryContainer + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ServiceAccountQuery implements OpenTaggedUnion, JsonpSerializable { + + /** + * {@link ServiceAccountQuery} variant kinds. + * + * @see API + * specification + */ + + public enum Kind implements JsonEnum { + Bool("bool"), + + Exists("exists"), + + Ids("ids"), + + Match("match"), + + MatchAll("match_all"), + + Prefix("prefix"), + + Range("range"), + + SimpleQueryString("simple_query_string"), + + Term("term"), + + Terms("terms"), + + Wildcard("wildcard"), + + /** A custom {@code ServiceAccountQuery} defined by a plugin */ + _Custom(null) + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + public ServiceAccountQuery(ServiceAccountQueryVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._serviceAccountQueryKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + this._customKind = null; + + } + + private ServiceAccountQuery(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + this._customKind = builder._customKind; + + } + + public static ServiceAccountQuery of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code bool}? + */ + public boolean isBool() { + return _kind == Kind.Bool; + } + + /** + * Get the {@code bool} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code bool} kind. + */ + public BoolQuery bool() { + return TaggedUnionUtils.get(this, Kind.Bool); + } + + /** + * Is this variant instance of kind {@code exists}? + */ + public boolean isExists() { + return _kind == Kind.Exists; + } + + /** + * Get the {@code exists} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code exists} kind. + */ + public ExistsQuery exists() { + return TaggedUnionUtils.get(this, Kind.Exists); + } + + /** + * Is this variant instance of kind {@code ids}? + */ + public boolean isIds() { + return _kind == Kind.Ids; + } + + /** + * Get the {@code ids} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code ids} kind. + */ + public IdsQuery ids() { + return TaggedUnionUtils.get(this, Kind.Ids); + } + + /** + * Is this variant instance of kind {@code match}? + */ + public boolean isMatch() { + return _kind == Kind.Match; + } + + /** + * Get the {@code match} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code match} kind. + */ + public NamedValue match() { + return TaggedUnionUtils.get(this, Kind.Match); + } + + /** + * Is this variant instance of kind {@code match_all}? + */ + public boolean isMatchAll() { + return _kind == Kind.MatchAll; + } + + /** + * Get the {@code match_all} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code match_all} kind. + */ + public MatchAllQuery matchAll() { + return TaggedUnionUtils.get(this, Kind.MatchAll); + } + + /** + * Is this variant instance of kind {@code prefix}? + */ + public boolean isPrefix() { + return _kind == Kind.Prefix; + } + + /** + * Get the {@code prefix} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code prefix} kind. + */ + public NamedValue prefix() { + return TaggedUnionUtils.get(this, Kind.Prefix); + } + + /** + * Is this variant instance of kind {@code range}? + */ + public boolean isRange() { + return _kind == Kind.Range; + } + + /** + * Get the {@code range} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code range} kind. + */ + public RangeQuery range() { + return TaggedUnionUtils.get(this, Kind.Range); + } + + /** + * Is this variant instance of kind {@code simple_query_string}? + */ + public boolean isSimpleQueryString() { + return _kind == Kind.SimpleQueryString; + } + + /** + * Get the {@code simple_query_string} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code simple_query_string} + * kind. + */ + public SimpleQueryStringQuery simpleQueryString() { + return TaggedUnionUtils.get(this, Kind.SimpleQueryString); + } + + /** + * Is this variant instance of kind {@code term}? + */ + public boolean isTerm() { + return _kind == Kind.Term; + } + + /** + * Get the {@code term} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code term} kind. + */ + public NamedValue term() { + return TaggedUnionUtils.get(this, Kind.Term); + } + + /** + * Is this variant instance of kind {@code terms}? + */ + public boolean isTerms() { + return _kind == Kind.Terms; + } + + /** + * Get the {@code terms} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code terms} kind. + */ + public TermsQuery terms() { + return TaggedUnionUtils.get(this, Kind.Terms); + } + + /** + * Is this variant instance of kind {@code wildcard}? + */ + public boolean isWildcard() { + return _kind == Kind.Wildcard; + } + + /** + * Get the {@code wildcard} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code wildcard} kind. + */ + public NamedValue wildcard() { + return TaggedUnionUtils.get(this, Kind.Wildcard); + } + + @Nullable + private final String _customKind; + + /** + * Is this a custom {@code ServiceAccountQuery} defined by a plugin? + */ + public boolean _isCustom() { + return _kind == Kind._Custom; + } + + /** + * Get the actual kind when {@code _kind()} equals {@link Kind#_Custom} + * (plugin-defined variant). + */ + @Nullable + public final String _customKind() { + return _customKind; + } + + /** + * Get the custom plugin-defined variant value. + * + * @throws IllegalStateException + * if the current variant is not {@link Kind#_Custom}. + */ + public JsonData _custom() { + return TaggedUnionUtils.get(this, Kind._Custom); + } + + @Override + @SuppressWarnings("unchecked") + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeStartObject(); + + generator.writeKey(_kind == Kind._Custom ? _customKind : _kind.jsonValue()); + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } else { + switch (_kind) { + case Match : + generator.writeStartObject(); + generator.writeKey(((NamedValue) this._value).name()); + ((NamedValue) this._value).value().serialize(generator, mapper); + + generator.writeEnd(); + + break; + case Prefix : + generator.writeStartObject(); + generator.writeKey(((NamedValue) this._value).name()); + ((NamedValue) this._value).value().serialize(generator, mapper); + + generator.writeEnd(); + + break; + case Term : + generator.writeStartObject(); + generator.writeKey(((NamedValue) this._value).name()); + ((NamedValue) this._value).value().serialize(generator, mapper); + + generator.writeEnd(); + + break; + case Wildcard : + generator.writeStartObject(); + generator.writeKey(((NamedValue) this._value).name()); + ((NamedValue) this._value).value().serialize(generator, mapper); + + generator.writeEnd(); + + break; + } + } + + generator.writeEnd(); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Kind _kind; + private Object _value; + private String _customKind; + + @Override + protected Builder self() { + return this; + } + public ObjectBuilder bool(BoolQuery v) { + this._kind = Kind.Bool; + this._value = v; + return this; + } + + public ObjectBuilder bool(Function> fn) { + return this.bool(fn.apply(new BoolQuery.Builder()).build()); + } + + public ObjectBuilder exists(ExistsQuery v) { + this._kind = Kind.Exists; + this._value = v; + return this; + } + + public ObjectBuilder exists(Function> fn) { + return this.exists(fn.apply(new ExistsQuery.Builder()).build()); + } + + public ObjectBuilder ids(IdsQuery v) { + this._kind = Kind.Ids; + this._value = v; + return this; + } + + public ObjectBuilder ids(Function> fn) { + return this.ids(fn.apply(new IdsQuery.Builder()).build()); + } + + public ObjectBuilder match(NamedValue v) { + this._kind = Kind.Match; + this._value = v; + return this; + } + + public ObjectBuilder matchAll(MatchAllQuery v) { + this._kind = Kind.MatchAll; + this._value = v; + return this; + } + + public ObjectBuilder matchAll( + Function> fn) { + return this.matchAll(fn.apply(new MatchAllQuery.Builder()).build()); + } + + public ObjectBuilder prefix(NamedValue v) { + this._kind = Kind.Prefix; + this._value = v; + return this; + } + + public ObjectBuilder range(RangeQuery v) { + this._kind = Kind.Range; + this._value = v; + return this; + } + + public ObjectBuilder range(Function> fn) { + return this.range(fn.apply(new RangeQuery.Builder()).build()); + } + + public ObjectBuilder simpleQueryString(SimpleQueryStringQuery v) { + this._kind = Kind.SimpleQueryString; + this._value = v; + return this; + } + + public ObjectBuilder simpleQueryString( + Function> fn) { + return this.simpleQueryString(fn.apply(new SimpleQueryStringQuery.Builder()).build()); + } + + public ObjectBuilder term(NamedValue v) { + this._kind = Kind.Term; + this._value = v; + return this; + } + + public ObjectBuilder terms(TermsQuery v) { + this._kind = Kind.Terms; + this._value = v; + return this; + } + + public ObjectBuilder terms(Function> fn) { + return this.terms(fn.apply(new TermsQuery.Builder()).build()); + } + + public ObjectBuilder wildcard(NamedValue v) { + this._kind = Kind.Wildcard; + this._value = v; + return this; + } + + /** + * Define this {@code ServiceAccountQuery} as a plugin-defined variant. + * + * @param name + * the plugin-defined identifier + * @param data + * the data for this custom {@code ServiceAccountQuery}. It is + * converted internally to {@link JsonData}. + */ + public ObjectBuilder _custom(String name, Object data) { + this._kind = Kind._Custom; + this._customKind = name; + this._value = JsonData.of(data); + return this; + } + + public ServiceAccountQuery build() { + _checkSingleUse(); + return new ServiceAccountQuery(this); + } + + } + + protected static void setupServiceAccountQueryDeserializer(ObjectDeserializer op) { + + op.add(Builder::bool, BoolQuery._DESERIALIZER, "bool"); + op.add(Builder::exists, ExistsQuery._DESERIALIZER, "exists"); + op.add(Builder::ids, IdsQuery._DESERIALIZER, "ids"); + op.add(Builder::match, NamedValue.deserializer(() -> MatchQuery._DESERIALIZER), "match"); + op.add(Builder::matchAll, MatchAllQuery._DESERIALIZER, "match_all"); + op.add(Builder::prefix, NamedValue.deserializer(() -> PrefixQuery._DESERIALIZER), "prefix"); + op.add(Builder::range, RangeQuery._DESERIALIZER, "range"); + op.add(Builder::simpleQueryString, SimpleQueryStringQuery._DESERIALIZER, "simple_query_string"); + op.add(Builder::term, NamedValue.deserializer(() -> TermQuery._DESERIALIZER), "term"); + op.add(Builder::terms, TermsQuery._DESERIALIZER, "terms"); + op.add(Builder::wildcard, NamedValue.deserializer(() -> WildcardQuery._DESERIALIZER), "wildcard"); + + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + JsonpUtils.ensureCustomVariantsAllowed(parser, mapper); + builder._custom(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); + + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ServiceAccountQuery::setupServiceAccountQueryDeserializer, Builder::build); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/ServiceAccountQueryBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/ServiceAccountQueryBuilders.java new file mode 100644 index 0000000000..1ddec85a17 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/ServiceAccountQueryBuilders.java @@ -0,0 +1,186 @@ +/* + * 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.security.query_service_accounts; + +import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.ExistsQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.IdsQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.MatchAllQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.RangeQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.SimpleQueryStringQuery; +import co.elastic.clients.elasticsearch._types.query_dsl.TermsQuery; +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link ServiceAccountQuery} variants. + *

    + * Variants match, prefix, term, + * wildcard are not available here as they don't have a dedicated + * class. Use {@link ServiceAccountQuery}'s builder for these. + * + */ +public class ServiceAccountQueryBuilders { + private ServiceAccountQueryBuilders() { + } + + /** + * Creates a builder for the {@link BoolQuery bool} {@code ServiceAccountQuery} + * variant. + */ + public static BoolQuery.Builder bool() { + return new BoolQuery.Builder(); + } + + /** + * Creates a ServiceAccountQuery of the {@link BoolQuery bool} + * {@code ServiceAccountQuery} variant. + */ + public static ServiceAccountQuery bool(Function> fn) { + ServiceAccountQuery.Builder builder = new ServiceAccountQuery.Builder(); + builder.bool(fn.apply(new BoolQuery.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link ExistsQuery exists} + * {@code ServiceAccountQuery} variant. + */ + public static ExistsQuery.Builder exists() { + return new ExistsQuery.Builder(); + } + + /** + * Creates a ServiceAccountQuery of the {@link ExistsQuery exists} + * {@code ServiceAccountQuery} variant. + */ + public static ServiceAccountQuery exists(Function> fn) { + ServiceAccountQuery.Builder builder = new ServiceAccountQuery.Builder(); + builder.exists(fn.apply(new ExistsQuery.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link IdsQuery ids} {@code ServiceAccountQuery} + * variant. + */ + public static IdsQuery.Builder ids() { + return new IdsQuery.Builder(); + } + + /** + * Creates a ServiceAccountQuery of the {@link IdsQuery ids} + * {@code ServiceAccountQuery} variant. + */ + public static ServiceAccountQuery ids(Function> fn) { + ServiceAccountQuery.Builder builder = new ServiceAccountQuery.Builder(); + builder.ids(fn.apply(new IdsQuery.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link MatchAllQuery match_all} + * {@code ServiceAccountQuery} variant. + */ + public static MatchAllQuery.Builder matchAll() { + return new MatchAllQuery.Builder(); + } + + /** + * Creates a ServiceAccountQuery of the {@link MatchAllQuery match_all} + * {@code ServiceAccountQuery} variant. + */ + public static ServiceAccountQuery matchAll(Function> fn) { + ServiceAccountQuery.Builder builder = new ServiceAccountQuery.Builder(); + builder.matchAll(fn.apply(new MatchAllQuery.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link RangeQuery range} + * {@code ServiceAccountQuery} variant. + */ + public static RangeQuery.Builder range() { + return new RangeQuery.Builder(); + } + + /** + * Creates a ServiceAccountQuery of the {@link RangeQuery range} + * {@code ServiceAccountQuery} variant. + */ + public static ServiceAccountQuery range(Function> fn) { + ServiceAccountQuery.Builder builder = new ServiceAccountQuery.Builder(); + builder.range(fn.apply(new RangeQuery.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link SimpleQueryStringQuery simple_query_string} + * {@code ServiceAccountQuery} variant. + */ + public static SimpleQueryStringQuery.Builder simpleQueryString() { + return new SimpleQueryStringQuery.Builder(); + } + + /** + * Creates a ServiceAccountQuery of the {@link SimpleQueryStringQuery + * simple_query_string} {@code ServiceAccountQuery} variant. + */ + public static ServiceAccountQuery simpleQueryString( + Function> fn) { + ServiceAccountQuery.Builder builder = new ServiceAccountQuery.Builder(); + builder.simpleQueryString(fn.apply(new SimpleQueryStringQuery.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link TermsQuery terms} + * {@code ServiceAccountQuery} variant. + */ + public static TermsQuery.Builder terms() { + return new TermsQuery.Builder(); + } + + /** + * Creates a ServiceAccountQuery of the {@link TermsQuery terms} + * {@code ServiceAccountQuery} variant. + */ + public static ServiceAccountQuery terms(Function> fn) { + ServiceAccountQuery.Builder builder = new ServiceAccountQuery.Builder(); + builder.terms(fn.apply(new TermsQuery.Builder()).build()); + return builder.build(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/ServiceAccountQueryVariant.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/ServiceAccountQueryVariant.java new file mode 100644 index 0000000000..62792612a9 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/query_service_accounts/ServiceAccountQueryVariant.java @@ -0,0 +1,48 @@ +/* + * 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.security.query_service_accounts; + +//---------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------- + +/** + * Base interface for {@link ServiceAccountQuery} variants. + */ +public interface ServiceAccountQueryVariant { + + ServiceAccountQuery.Kind _serviceAccountQueryKind(); + + default ServiceAccountQuery _toServiceAccountQuery() { + return new ServiceAccountQuery(this); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepositorySettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepositorySettings.java index 7c2c0a7290..a1fce1153d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepositorySettings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepositorySettings.java @@ -67,6 +67,9 @@ public class AzureRepositorySettings extends RepositorySettingsBase { @Nullable private final String container; + @Nullable + private final String dataAccessTier; + @Nullable private final Integer deleteObjectsMaxSize; @@ -76,6 +79,9 @@ public class AzureRepositorySettings extends RepositorySettingsBase { @Nullable private final Integer maxConcurrentBatchDeletes; + @Nullable + private final String metadataAccessTier; + @Nullable private final Boolean readonly; @@ -87,9 +93,11 @@ private AzureRepositorySettings(Builder builder) { this.basePath = builder.basePath; this.client = builder.client; this.container = builder.container; + this.dataAccessTier = builder.dataAccessTier; this.deleteObjectsMaxSize = builder.deleteObjectsMaxSize; this.locationMode = builder.locationMode; this.maxConcurrentBatchDeletes = builder.maxConcurrentBatchDeletes; + this.metadataAccessTier = builder.metadataAccessTier; this.readonly = builder.readonly; } @@ -134,6 +142,20 @@ public final String container() { return this.container; } + /** + * The Azure access tier applied to the data blobs of the repository, which hold + * the files that make up each snapshotted shard. Accepted values are + * hot, cool and cold, in any letter + * case. If not set, no access tier is requested and Azure applies the default + * tier of the storage account. + *

    + * API name: {@code data_access_tier} + */ + @Nullable + public final String dataAccessTier() { + return this.dataAccessTier; + } + /** * The maxmimum batch size, between 1 and 256, used for BlobBatch * requests. Defaults to 256 which is the maximum number supported by the Azure @@ -172,6 +194,21 @@ public final Integer maxConcurrentBatchDeletes() { return this.maxConcurrentBatchDeletes; } + /** + * The Azure access tier applied to the metadata blobs of the repository. These + * are generally smaller than the data blobs but can be read more often, for + * example to list the repository contents or to take snapshots. Accepted values + * are hot, cool and cold, in any letter + * case. If not set, no access tier is requested and Azure applies the default + * tier of the storage account. + *

    + * API name: {@code metadata_access_tier} + */ + @Nullable + public final String metadataAccessTier() { + return this.metadataAccessTier; + } + /** * If true, the repository is read-only. The cluster can retrieve * and restore snapshots from the repository but not write to the repository or @@ -212,6 +249,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("container"); generator.write(this.container); + } + if (this.dataAccessTier != null) { + generator.writeKey("data_access_tier"); + generator.write(this.dataAccessTier); + } if (this.deleteObjectsMaxSize != null) { generator.writeKey("delete_objects_max_size"); @@ -227,6 +269,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("max_concurrent_batch_deletes"); generator.write(this.maxConcurrentBatchDeletes); + } + if (this.metadataAccessTier != null) { + generator.writeKey("metadata_access_tier"); + generator.write(this.metadataAccessTier); + } if (this.readonly != null) { generator.writeKey("readonly"); @@ -254,6 +301,9 @@ public static class Builder extends RepositorySettingsBase.AbstractBuilderhot, cool and cold, in any letter + * case. If not set, no access tier is requested and Azure applies the default + * tier of the storage account. + *

    + * API name: {@code data_access_tier} + */ + public final Builder dataAccessTier(@Nullable String value) { + this.dataAccessTier = value; + return this; + } + /** * The maxmimum batch size, between 1 and 256, used for BlobBatch * requests. Defaults to 256 which is the maximum number supported by the Azure @@ -352,6 +421,21 @@ public final Builder maxConcurrentBatchDeletes(@Nullable Integer value) { return this; } + /** + * The Azure access tier applied to the metadata blobs of the repository. These + * are generally smaller than the data blobs but can be read more often, for + * example to list the repository contents or to take snapshots. Accepted values + * are hot, cool and cold, in any letter + * case. If not set, no access tier is requested and Azure applies the default + * tier of the storage account. + *

    + * API name: {@code metadata_access_tier} + */ + public final Builder metadataAccessTier(@Nullable String value) { + this.metadataAccessTier = value; + return this; + } + /** * If true, the repository is read-only. The cluster can retrieve * and restore snapshots from the repository but not write to the repository or @@ -413,10 +497,12 @@ protected static void setupAzureRepositorySettingsDeserializer( op.add(Builder::basePath, JsonpDeserializer.stringDeserializer(), "base_path"); op.add(Builder::client, JsonpDeserializer.stringDeserializer(), "client"); op.add(Builder::container, JsonpDeserializer.stringDeserializer(), "container"); + op.add(Builder::dataAccessTier, JsonpDeserializer.stringDeserializer(), "data_access_tier"); op.add(Builder::deleteObjectsMaxSize, JsonpDeserializer.integerDeserializer(), "delete_objects_max_size"); op.add(Builder::locationMode, JsonpDeserializer.stringDeserializer(), "location_mode"); op.add(Builder::maxConcurrentBatchDeletes, JsonpDeserializer.integerDeserializer(), "max_concurrent_batch_deletes"); + op.add(Builder::metadataAccessTier, JsonpDeserializer.stringDeserializer(), "metadata_access_tier"); op.add(Builder::readonly, JsonpDeserializer.booleanDeserializer(), "readonly"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RestoreRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RestoreRequest.java index b4793dd98e..fe1c35662a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RestoreRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RestoreRequest.java @@ -126,6 +126,9 @@ public class RestoreRequest extends RequestBase implements JsonpSerializable { private final String repository; + @Nullable + private final Boolean restoreOverExisting; + private final String snapshot; @Nullable @@ -147,6 +150,7 @@ private RestoreRequest(Builder builder) { this.renamePattern = builder.renamePattern; this.renameReplacement = builder.renameReplacement; this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository"); + this.restoreOverExisting = builder.restoreOverExisting; this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); this.waitForCompletion = builder.waitForCompletion; @@ -336,6 +340,24 @@ public final String repository() { return this.repository; } + /** + * If true, the request can restore over destination indices and + * data streams that already exist, without closing or deleting them first. An + * open destination index is closed and restored over in a single step. A + * destination data stream is deleted, together with its backing and failure + * store indices, and recreated from the snapshot. + *

    + * It can't be combined with rename_pattern, + * rename_replacement, include_global_state, or + * partial. + *

    + * API name: {@code restore_over_existing} + */ + @Nullable + public final Boolean restoreOverExisting() { + return this.restoreOverExisting; + } + /** * Required - The name of the snapshot to restore. *

    @@ -437,6 +459,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.renameReplacement); } + if (this.restoreOverExisting != null) { + generator.writeKey("restore_over_existing"); + generator.write(this.restoreOverExisting); + + } } @@ -482,6 +509,9 @@ public static class Builder extends RequestBase.AbstractBuilder impleme private String repository; + @Nullable + private Boolean restoreOverExisting; + private String snapshot; @Nullable @@ -502,6 +532,7 @@ private Builder(RestoreRequest instance) { this.renamePattern = instance.renamePattern; this.renameReplacement = instance.renameReplacement; this.repository = instance.repository; + this.restoreOverExisting = instance.restoreOverExisting; this.snapshot = instance.snapshot; this.waitForCompletion = instance.waitForCompletion; @@ -775,6 +806,24 @@ public final Builder repository(String value) { return this; } + /** + * If true, the request can restore over destination indices and + * data streams that already exist, without closing or deleting them first. An + * open destination index is closed and restored over in a single step. A + * destination data stream is deleted, together with its backing and failure + * store indices, and recreated from the snapshot. + *

    + * It can't be combined with rename_pattern, + * rename_replacement, include_global_state, or + * partial. + *

    + * API name: {@code restore_over_existing} + */ + public final Builder restoreOverExisting(@Nullable Boolean value) { + this.restoreOverExisting = value; + return this; + } + /** * Required - The name of the snapshot to restore. *

    @@ -848,6 +897,7 @@ protected static void setupRestoreRequestDeserializer(ObjectDeserializerhot, cool and cold, in any letter + * case. If not set, no access tier is requested and Azure applies the default + * tier of the storage account. + *

    + * API name: {@code data_access_tier} + */ + @Nullable + public final String dataAccessTier() { + return this.dataAccessTier; + } + /** * The maxmimum batch size, between 1 and 256, used for BlobBatch * requests. Defaults to 256 which is the maximum number supported by the Azure @@ -183,6 +205,21 @@ public final Integer maxConcurrentBatchDeletes() { return this.maxConcurrentBatchDeletes; } + /** + * The Azure access tier applied to the metadata blobs of the repository. These + * are generally smaller than the data blobs but can be read more often, for + * example to list the repository contents or to take snapshots. Accepted values + * are hot, cool and cold, in any letter + * case. If not set, no access tier is requested and Azure applies the default + * tier of the storage account. + *

    + * API name: {@code metadata_access_tier} + */ + @Nullable + public final String metadataAccessTier() { + return this.metadataAccessTier; + } + /** * If true, the repository is read-only. The cluster can retrieve * and restore snapshots from the repository but not write to the repository or @@ -233,6 +270,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("container"); generator.write(this.container); + } + if (this.dataAccessTier != null) { + generator.writeKey("data_access_tier"); + generator.write(this.dataAccessTier); + } if (this.deleteObjectsMaxSize != null) { generator.writeKey("delete_objects_max_size"); @@ -248,6 +290,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("max_concurrent_batch_deletes"); generator.write(this.maxConcurrentBatchDeletes); + } + if (this.metadataAccessTier != null) { + generator.writeKey("metadata_access_tier"); + generator.write(this.metadataAccessTier); + } if (this.readonly != null) { generator.writeKey("readonly"); @@ -280,6 +327,9 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private String container; + @Nullable + private String dataAccessTier; + @Nullable private Integer deleteObjectsMaxSize; @@ -289,6 +339,9 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Integer maxConcurrentBatchDeletes; + @Nullable + private String metadataAccessTier; + @Nullable private Boolean readonly; @@ -298,9 +351,11 @@ private Builder(SourceOnlyRepositorySettingsForAzure instance) { this.basePath = instance.basePath; this.client = instance.client; this.container = instance.container; + this.dataAccessTier = instance.dataAccessTier; this.deleteObjectsMaxSize = instance.deleteObjectsMaxSize; this.locationMode = instance.locationMode; this.maxConcurrentBatchDeletes = instance.maxConcurrentBatchDeletes; + this.metadataAccessTier = instance.metadataAccessTier; this.readonly = instance.readonly; } @@ -340,6 +395,20 @@ public final Builder container(@Nullable String value) { return this; } + /** + * The Azure access tier applied to the data blobs of the repository, which hold + * the files that make up each snapshotted shard. Accepted values are + * hot, cool and cold, in any letter + * case. If not set, no access tier is requested and Azure applies the default + * tier of the storage account. + *

    + * API name: {@code data_access_tier} + */ + public final Builder dataAccessTier(@Nullable String value) { + this.dataAccessTier = value; + return this; + } + /** * The maxmimum batch size, between 1 and 256, used for BlobBatch * requests. Defaults to 256 which is the maximum number supported by the Azure @@ -378,6 +447,21 @@ public final Builder maxConcurrentBatchDeletes(@Nullable Integer value) { return this; } + /** + * The Azure access tier applied to the metadata blobs of the repository. These + * are generally smaller than the data blobs but can be read more often, for + * example to list the repository contents or to take snapshots. Accepted values + * are hot, cool and cold, in any letter + * case. If not set, no access tier is requested and Azure applies the default + * tier of the storage account. + *

    + * API name: {@code metadata_access_tier} + */ + public final Builder metadataAccessTier(@Nullable String value) { + this.metadataAccessTier = value; + return this; + } + /** * If true, the repository is read-only. The cluster can retrieve * and restore snapshots from the repository but not write to the repository or @@ -440,10 +524,12 @@ protected static void setupSourceOnlyRepositorySettingsForAzureDeserializer( op.add(Builder::basePath, JsonpDeserializer.stringDeserializer(), "base_path"); op.add(Builder::client, JsonpDeserializer.stringDeserializer(), "client"); op.add(Builder::container, JsonpDeserializer.stringDeserializer(), "container"); + op.add(Builder::dataAccessTier, JsonpDeserializer.stringDeserializer(), "data_access_tier"); op.add(Builder::deleteObjectsMaxSize, JsonpDeserializer.integerDeserializer(), "delete_objects_max_size"); op.add(Builder::locationMode, JsonpDeserializer.stringDeserializer(), "location_mode"); op.add(Builder::maxConcurrentBatchDeletes, JsonpDeserializer.integerDeserializer(), "max_concurrent_batch_deletes"); + op.add(Builder::metadataAccessTier, JsonpDeserializer.stringDeserializer(), "metadata_access_tier"); op.add(Builder::readonly, JsonpDeserializer.booleanDeserializer(), "readonly"); op.ignore("delegate_type"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/transform/Settings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/transform/Settings.java index 5f46e5cb82..3aec62e51f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/transform/Settings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/transform/Settings.java @@ -19,6 +19,7 @@ package co.elastic.clients.elasticsearch.transform; +import co.elastic.clients.elasticsearch._types.Time; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -85,6 +86,9 @@ public class Settings implements JsonpSerializable { @Nullable private final Boolean unattended; + @Nullable + private final Time indexerRequestTimeout; + // --------------------------------------------------------------------------------------------- private Settings(Builder builder) { @@ -97,6 +101,7 @@ private Settings(Builder builder) { this.usePointInTime = builder.usePointInTime; this.numFailureRetries = builder.numFailureRetries; this.unattended = builder.unattended; + this.indexerRequestTimeout = builder.indexerRequestTimeout; } @@ -119,8 +124,8 @@ public final Boolean alignCheckpoints() { } /** - * Defines if dates in the ouput should be written as ISO formatted string or as - * millis since epoch. epoch_millis was the default for transforms created + * Defines if dates in the output should be written as ISO formatted string or + * as millis since epoch. epoch_millis was the default for transforms created * before version 7.11. For compatible output set this value to * true. *

    @@ -215,6 +220,19 @@ public final Boolean unattended() { return this.unattended; } + /** + * The initial timeout for the requests the transform sends to nodes to retrieve + * checkpoint information. Each consecutive failure doubles the timeout, up to a + * maximum of 12h. The minimum value is 1ms and the + * maximum is 12h. Defaults to 30s. + *

    + * API name: {@code indexer_request_timeout} + */ + @Nullable + public final Time indexerRequestTimeout() { + return this.indexerRequestTimeout; + } + /** * Serialize this object to JSON. */ @@ -266,6 +284,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.unattended); } + if (this.indexerRequestTimeout != null) { + generator.writeKey("indexer_request_timeout"); + this.indexerRequestTimeout.serialize(generator, mapper); + + } } @@ -305,6 +328,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private Boolean unattended; + @Nullable + private Time indexerRequestTimeout; + public Builder() { } private Builder(Settings instance) { @@ -316,6 +342,7 @@ private Builder(Settings instance) { this.usePointInTime = instance.usePointInTime; this.numFailureRetries = instance.numFailureRetries; this.unattended = instance.unattended; + this.indexerRequestTimeout = instance.indexerRequestTimeout; } /** @@ -333,8 +360,8 @@ public final Builder alignCheckpoints(@Nullable Boolean value) { } /** - * Defines if dates in the ouput should be written as ISO formatted string or as - * millis since epoch. epoch_millis was the default for transforms created + * Defines if dates in the output should be written as ISO formatted string or + * as millis since epoch. epoch_millis was the default for transforms created * before version 7.11. For compatible output set this value to * true. *

    @@ -429,6 +456,31 @@ public final Builder unattended(@Nullable Boolean value) { return this; } + /** + * The initial timeout for the requests the transform sends to nodes to retrieve + * checkpoint information. Each consecutive failure doubles the timeout, up to a + * maximum of 12h. The minimum value is 1ms and the + * maximum is 12h. Defaults to 30s. + *

    + * API name: {@code indexer_request_timeout} + */ + public final Builder indexerRequestTimeout(@Nullable Time value) { + this.indexerRequestTimeout = value; + return this; + } + + /** + * The initial timeout for the requests the transform sends to nodes to retrieve + * checkpoint information. Each consecutive failure doubles the timeout, up to a + * maximum of 12h. The minimum value is 1ms and the + * maximum is 12h. Defaults to 30s. + *

    + * API name: {@code indexer_request_timeout} + */ + public final Builder indexerRequestTimeout(Function> fn) { + return this.indexerRequestTimeout(fn.apply(new Time.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -471,6 +523,7 @@ protected static void setupSettingsDeserializer(ObjectDeserializersync.time.delay of + * the transform. Only applicable for continuous transforms, and it can't be + * greater than sync.time.delay. + *

    + * API name: {@code initial_delay} + */ + @Nullable + public final Time initialDelay() { + return this.initialDelay; + } + /** * Period to wait for a response. If no response is received before the timeout * expires, the request fails and returns an error. @@ -152,6 +169,9 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private String from; + @Nullable + private Time initialDelay; + @Nullable private Time timeout; @@ -161,6 +181,7 @@ public Builder() { } private Builder(StartTransformRequest instance) { this.from = instance.from; + this.initialDelay = instance.initialDelay; this.timeout = instance.timeout; this.transformId = instance.transformId; @@ -177,6 +198,31 @@ public final Builder from(@Nullable String value) { return this; } + /** + * A one-time, reduced sync delay that applies until the transform has processed + * its first document. It then reverts to the sync.time.delay of + * the transform. Only applicable for continuous transforms, and it can't be + * greater than sync.time.delay. + *

    + * API name: {@code initial_delay} + */ + public final Builder initialDelay(@Nullable Time value) { + this.initialDelay = value; + return this; + } + + /** + * A one-time, reduced sync delay that applies until the transform has processed + * its first document. It then reverts to the sync.time.delay of + * the transform. Only applicable for continuous transforms, and it can't be + * greater than sync.time.delay. + *

    + * API name: {@code initial_delay} + */ + public final Builder initialDelay(Function> fn) { + return this.initialDelay(fn.apply(new Time.Builder()).build()); + } + /** * Period to wait for a response. If no response is received before the timeout * expires, the request fails and returns an error. @@ -284,6 +330,9 @@ public Builder rebuild() { // Request parameters request -> { Map params = new HashMap<>(); + if (request.initialDelay != null) { + params.put("initial_delay", request.initialDelay._toJsonString()); + } if (request.from != null) { params.put("from", request.from); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/transform/UpdateTransformResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/transform/UpdateTransformResponse.java index 03229e27e3..01550c5339 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/transform/UpdateTransformResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/transform/UpdateTransformResponse.java @@ -71,6 +71,7 @@ public class UpdateTransformResponse implements JsonpSerializable { private final long createTime; + @Nullable private final String description; private final Destination dest; @@ -106,7 +107,7 @@ private UpdateTransformResponse(Builder builder) { this.authorization = builder.authorization; this.createTime = ApiTypeHelper.requireNonNull(builder.createTime, this, "createTime", 0); - this.description = ApiTypeHelper.requireNonNull(builder.description, this, "description"); + this.description = builder.description; this.dest = ApiTypeHelper.requireNonNull(builder.dest, this, "dest"); this.frequency = builder.frequency; this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); @@ -141,8 +142,9 @@ public final long createTime() { } /** - * Required - API name: {@code description} + * API name: {@code description} */ + @Nullable public final String description() { return this.description; } @@ -248,9 +250,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("create_time"); generator.write(this.createTime); - generator.writeKey("description"); - generator.write(this.description); + if (this.description != null) { + generator.writeKey("description"); + generator.write(this.description); + } generator.writeKey("dest"); this.dest.serialize(generator, mapper); @@ -324,6 +328,7 @@ public static class Builder extends WithJsonObjectBuilderBase private Long createTime; + @Nullable private String description; private Destination dest; @@ -379,9 +384,9 @@ public final Builder createTime(long value) { } /** - * Required - API name: {@code description} + * API name: {@code description} */ - public final Builder description(String value) { + public final Builder description(@Nullable String value) { this.description = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/XpackUsageResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/XpackUsageResponse.java index 8d7e3e5a86..186c448c5f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/XpackUsageResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/XpackUsageResponse.java @@ -31,6 +31,7 @@ import co.elastic.clients.elasticsearch.xpack.usage.GpuVectorIndexing; import co.elastic.clients.elasticsearch.xpack.usage.HealthStatistics; import co.elastic.clients.elasticsearch.xpack.usage.Ilm; +import co.elastic.clients.elasticsearch.xpack.usage.IndexModeUsage; import co.elastic.clients.elasticsearch.xpack.usage.Logging; import co.elastic.clients.elasticsearch.xpack.usage.MachineLearning; import co.elastic.clients.elasticsearch.xpack.usage.Monitoring; @@ -40,6 +41,7 @@ import co.elastic.clients.elasticsearch.xpack.usage.Slm; import co.elastic.clients.elasticsearch.xpack.usage.Sql; import co.elastic.clients.elasticsearch.xpack.usage.Vector; +import co.elastic.clients.elasticsearch.xpack.usage.VectorDbColumnar; import co.elastic.clients.elasticsearch.xpack.usage.VectorDbDocument; import co.elastic.clients.elasticsearch.xpack.usage.Watcher; import co.elastic.clients.json.JsonpDeserializable; @@ -91,6 +93,9 @@ public class XpackUsageResponse implements JsonpSerializable { private final Ccr ccr; + @Nullable + private final IndexModeUsage columnar; + @Nullable private final Base dataFrame; @@ -126,6 +131,9 @@ public class XpackUsageResponse implements JsonpSerializable { @Nullable private final Logging logging; + @Nullable + private final IndexModeUsage logsdbColumnar; + private final Base logstash; private final MachineLearning ml; @@ -155,6 +163,9 @@ public class XpackUsageResponse implements JsonpSerializable { @Nullable private final VectorDbDocument vectordbDocument; + @Nullable + private final VectorDbColumnar vectordbColumnar; + private final Base votingOnly; // --------------------------------------------------------------------------------------------- @@ -166,6 +177,7 @@ private XpackUsageResponse(Builder builder) { this.archive = ApiTypeHelper.requireNonNull(builder.archive, this, "archive"); this.watcher = ApiTypeHelper.requireNonNull(builder.watcher, this, "watcher"); this.ccr = ApiTypeHelper.requireNonNull(builder.ccr, this, "ccr"); + this.columnar = builder.columnar; this.dataFrame = builder.dataFrame; this.dataScience = builder.dataScience; this.dataLifecycle = builder.dataLifecycle; @@ -179,6 +191,7 @@ private XpackUsageResponse(Builder builder) { this.healthApi = builder.healthApi; this.ilm = ApiTypeHelper.requireNonNull(builder.ilm, this, "ilm"); this.logging = builder.logging; + this.logsdbColumnar = builder.logsdbColumnar; this.logstash = ApiTypeHelper.requireNonNull(builder.logstash, this, "logstash"); this.ml = ApiTypeHelper.requireNonNull(builder.ml, this, "ml"); this.monitoring = ApiTypeHelper.requireNonNull(builder.monitoring, this, "monitoring"); @@ -193,6 +206,7 @@ private XpackUsageResponse(Builder builder) { this.transform = ApiTypeHelper.requireNonNull(builder.transform, this, "transform"); this.vectors = builder.vectors; this.vectordbDocument = builder.vectordbDocument; + this.vectordbColumnar = builder.vectordbColumnar; this.votingOnly = ApiTypeHelper.requireNonNull(builder.votingOnly, this, "votingOnly"); } @@ -236,6 +250,17 @@ public final Ccr ccr() { return this.ccr; } + /** + * Usage of the indices with index.mode set to + * columnar. + *

    + * API name: {@code columnar} + */ + @Nullable + public final IndexModeUsage columnar() { + return this.columnar; + } + /** * API name: {@code data_frame} */ @@ -336,6 +361,17 @@ public final Logging logging() { return this.logging; } + /** + * Usage of the indices with index.mode set to + * logsdb_columnar. + *

    + * API name: {@code logsdb_columnar} + */ + @Nullable + public final IndexModeUsage logsdbColumnar() { + return this.logsdbColumnar; + } + /** * Required - API name: {@code logstash} */ @@ -430,6 +466,18 @@ public final VectorDbDocument vectordbDocument() { return this.vectordbDocument; } + /** + * The vectordb_columnar index mode is behind a feature flag. + * Without the flag, this section is still returned, disabled and with zero + * counts. + *

    + * API name: {@code vectordb_columnar} + */ + @Nullable + public final VectorDbColumnar vectordbColumnar() { + return this.vectordbColumnar; + } + /** * Required - API name: {@code voting_only} */ @@ -463,6 +511,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("ccr"); this.ccr.serialize(generator, mapper); + if (this.columnar != null) { + generator.writeKey("columnar"); + this.columnar.serialize(generator, mapper); + + } if (this.dataFrame != null) { generator.writeKey("data_frame"); this.dataFrame.serialize(generator, mapper); @@ -519,6 +572,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("logging"); this.logging.serialize(generator, mapper); + } + if (this.logsdbColumnar != null) { + generator.writeKey("logsdb_columnar"); + this.logsdbColumnar.serialize(generator, mapper); + } generator.writeKey("logstash"); this.logstash.serialize(generator, mapper); @@ -564,6 +622,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("vectordb_document"); this.vectordbDocument.serialize(generator, mapper); + } + if (this.vectordbColumnar != null) { + generator.writeKey("vectordb_columnar"); + this.vectordbColumnar.serialize(generator, mapper); + } generator.writeKey("voting_only"); this.votingOnly.serialize(generator, mapper); @@ -594,6 +657,9 @@ public static class Builder extends WithJsonObjectBuilderBase private Ccr ccr; + @Nullable + private IndexModeUsage columnar; + @Nullable private Base dataFrame; @@ -629,6 +695,9 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Logging logging; + @Nullable + private IndexModeUsage logsdbColumnar; + private Base logstash; private MachineLearning ml; @@ -658,6 +727,9 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private VectorDbDocument vectordbDocument; + @Nullable + private VectorDbColumnar vectordbColumnar; + private Base votingOnly; /** @@ -735,6 +807,27 @@ public final Builder ccr(Function> fn) { return this.ccr(fn.apply(new Ccr.Builder()).build()); } + /** + * Usage of the indices with index.mode set to + * columnar. + *

    + * API name: {@code columnar} + */ + public final Builder columnar(@Nullable IndexModeUsage value) { + this.columnar = value; + return this; + } + + /** + * Usage of the indices with index.mode set to + * columnar. + *

    + * API name: {@code columnar} + */ + public final Builder columnar(Function> fn) { + return this.columnar(fn.apply(new IndexModeUsage.Builder()).build()); + } + /** * API name: {@code data_frame} */ @@ -932,6 +1025,27 @@ public final Builder logging(Function> f return this.logging(fn.apply(new Logging.Builder()).build()); } + /** + * Usage of the indices with index.mode set to + * logsdb_columnar. + *

    + * API name: {@code logsdb_columnar} + */ + public final Builder logsdbColumnar(@Nullable IndexModeUsage value) { + this.logsdbColumnar = value; + return this; + } + + /** + * Usage of the indices with index.mode set to + * logsdb_columnar. + *

    + * API name: {@code logsdb_columnar} + */ + public final Builder logsdbColumnar(Function> fn) { + return this.logsdbColumnar(fn.apply(new IndexModeUsage.Builder()).build()); + } + /** * Required - API name: {@code logstash} */ @@ -1128,6 +1242,29 @@ public final Builder vectordbDocument(Functionvectordb_columnar index mode is behind a feature flag. + * Without the flag, this section is still returned, disabled and with zero + * counts. + *

    + * API name: {@code vectordb_columnar} + */ + public final Builder vectordbColumnar(@Nullable VectorDbColumnar value) { + this.vectordbColumnar = value; + return this; + } + + /** + * The vectordb_columnar index mode is behind a feature flag. + * Without the flag, this section is still returned, disabled and with zero + * counts. + *

    + * API name: {@code vectordb_columnar} + */ + public final Builder vectordbColumnar(Function> fn) { + return this.vectordbColumnar(fn.apply(new VectorDbColumnar.Builder()).build()); + } + /** * Required - API name: {@code voting_only} */ @@ -1176,6 +1313,7 @@ protected static void setupXpackUsageResponseDeserializer(ObjectDeserializer implement private Feature ccr; + @Nullable + private Feature columnar; + private Feature dataStreams; private Feature dataTiers; @@ -515,6 +552,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Feature logsdb; + @Nullable + private Feature logsdbColumnar; + private Feature ml; private Feature monitoring; @@ -552,6 +592,7 @@ private Builder(Features instance) { this.aggregateMetric = instance.aggregateMetric; this.analytics = instance.analytics; this.ccr = instance.ccr; + this.columnar = instance.columnar; this.dataStreams = instance.dataStreams; this.dataTiers = instance.dataTiers; this.enrich = instance.enrich; @@ -563,6 +604,7 @@ private Builder(Features instance) { this.ilm = instance.ilm; this.logstash = instance.logstash; this.logsdb = instance.logsdb; + this.logsdbColumnar = instance.logsdbColumnar; this.ml = instance.ml; this.monitoring = instance.monitoring; this.rollup = instance.rollup; @@ -624,6 +666,21 @@ public final Builder ccr(Function> fn) { return this.ccr(fn.apply(new Feature.Builder()).build()); } + /** + * Required - API name: {@code columnar} + */ + public final Builder columnar(@Nullable Feature value) { + this.columnar = value; + return this; + } + + /** + * Required - API name: {@code columnar} + */ + public final Builder columnar(Function> fn) { + return this.columnar(fn.apply(new Feature.Builder()).build()); + } + /** * Required - API name: {@code data_streams} */ @@ -789,6 +846,21 @@ public final Builder logsdb(Function> fn return this.logsdb(fn.apply(new Feature.Builder()).build()); } + /** + * Required - API name: {@code logsdb_columnar} + */ + public final Builder logsdbColumnar(@Nullable Feature value) { + this.logsdbColumnar = value; + return this; + } + + /** + * Required - API name: {@code logsdb_columnar} + */ + public final Builder logsdbColumnar(Function> fn) { + return this.logsdbColumnar(fn.apply(new Feature.Builder()).build()); + } + /** * Required - API name: {@code ml} */ @@ -1036,6 +1108,7 @@ protected static void setupFeaturesDeserializer(ObjectDeserializerindex.mode. + * + * @see API + * specification + */ +@JsonpDeserializable +public class IndexModeUsage extends Base { + private final long indicesCount; + + private final long indicesWithSyntheticSource; + + private final long numDocs; + + private final long sizeInBytes; + + private final long dataStreamsCount; + + private final long dataStreamsManagedByIlm; + + private final long dataStreamsManagedByDlm; + + // --------------------------------------------------------------------------------------------- + + private IndexModeUsage(Builder builder) { + super(builder); + + this.indicesCount = ApiTypeHelper.requireNonNull(builder.indicesCount, this, "indicesCount", 0); + this.indicesWithSyntheticSource = ApiTypeHelper.requireNonNull(builder.indicesWithSyntheticSource, this, + "indicesWithSyntheticSource", 0); + this.numDocs = ApiTypeHelper.requireNonNull(builder.numDocs, this, "numDocs", 0); + this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes", 0); + this.dataStreamsCount = ApiTypeHelper.requireNonNull(builder.dataStreamsCount, this, "dataStreamsCount", 0); + this.dataStreamsManagedByIlm = ApiTypeHelper.requireNonNull(builder.dataStreamsManagedByIlm, this, + "dataStreamsManagedByIlm", 0); + this.dataStreamsManagedByDlm = ApiTypeHelper.requireNonNull(builder.dataStreamsManagedByDlm, this, + "dataStreamsManagedByDlm", 0); + + } + + public static IndexModeUsage of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The number of indices in this index mode. + *

    + * API name: {@code indices_count} + */ + public final long indicesCount() { + return this.indicesCount; + } + + /** + * Required - The number of indices in this index mode that use synthetic + * _source. + *

    + * API name: {@code indices_with_synthetic_source} + */ + public final long indicesWithSyntheticSource() { + return this.indicesWithSyntheticSource; + } + + /** + * Required - The number of documents in the indices in this index mode. + *

    + * API name: {@code num_docs} + */ + public final long numDocs() { + return this.numDocs; + } + + /** + * Required - The size of the indices in this index mode, in bytes. + *

    + * API name: {@code size_in_bytes} + */ + public final long sizeInBytes() { + return this.sizeInBytes; + } + + /** + * Required - The number of data streams in this index mode. + *

    + * API name: {@code data_streams_count} + */ + public final long dataStreamsCount() { + return this.dataStreamsCount; + } + + /** + * Required - The number of data streams in this index mode that are managed by + * index lifecycle management. + *

    + * API name: {@code data_streams_managed_by_ilm} + */ + public final long dataStreamsManagedByIlm() { + return this.dataStreamsManagedByIlm; + } + + /** + * Required - The number of data streams in this index mode that are managed by + * data stream lifecycle. + *

    + * API name: {@code data_streams_managed_by_dlm} + */ + public final long dataStreamsManagedByDlm() { + return this.dataStreamsManagedByDlm; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + generator.writeKey("indices_count"); + generator.write(this.indicesCount); + + generator.writeKey("indices_with_synthetic_source"); + generator.write(this.indicesWithSyntheticSource); + + generator.writeKey("num_docs"); + generator.write(this.numDocs); + + generator.writeKey("size_in_bytes"); + generator.write(this.sizeInBytes); + + generator.writeKey("data_streams_count"); + generator.write(this.dataStreamsCount); + + generator.writeKey("data_streams_managed_by_ilm"); + generator.write(this.dataStreamsManagedByIlm); + + generator.writeKey("data_streams_managed_by_dlm"); + generator.write(this.dataStreamsManagedByDlm); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link IndexModeUsage}. + */ + + public static class Builder extends Base.AbstractBuilder implements ObjectBuilder { + private Long indicesCount; + + private Long indicesWithSyntheticSource; + + private Long numDocs; + + private Long sizeInBytes; + + private Long dataStreamsCount; + + private Long dataStreamsManagedByIlm; + + private Long dataStreamsManagedByDlm; + + public Builder() { + } + private Builder(IndexModeUsage instance) { + this.indicesCount = instance.indicesCount; + this.indicesWithSyntheticSource = instance.indicesWithSyntheticSource; + this.numDocs = instance.numDocs; + this.sizeInBytes = instance.sizeInBytes; + this.dataStreamsCount = instance.dataStreamsCount; + this.dataStreamsManagedByIlm = instance.dataStreamsManagedByIlm; + this.dataStreamsManagedByDlm = instance.dataStreamsManagedByDlm; + + } + /** + * Required - The number of indices in this index mode. + *

    + * API name: {@code indices_count} + */ + public final Builder indicesCount(long value) { + this.indicesCount = value; + return this; + } + + /** + * Required - The number of indices in this index mode that use synthetic + * _source. + *

    + * API name: {@code indices_with_synthetic_source} + */ + public final Builder indicesWithSyntheticSource(long value) { + this.indicesWithSyntheticSource = value; + return this; + } + + /** + * Required - The number of documents in the indices in this index mode. + *

    + * API name: {@code num_docs} + */ + public final Builder numDocs(long value) { + this.numDocs = value; + return this; + } + + /** + * Required - The size of the indices in this index mode, in bytes. + *

    + * API name: {@code size_in_bytes} + */ + public final Builder sizeInBytes(long value) { + this.sizeInBytes = value; + return this; + } + + /** + * Required - The number of data streams in this index mode. + *

    + * API name: {@code data_streams_count} + */ + public final Builder dataStreamsCount(long value) { + this.dataStreamsCount = value; + return this; + } + + /** + * Required - The number of data streams in this index mode that are managed by + * index lifecycle management. + *

    + * API name: {@code data_streams_managed_by_ilm} + */ + public final Builder dataStreamsManagedByIlm(long value) { + this.dataStreamsManagedByIlm = value; + return this; + } + + /** + * Required - The number of data streams in this index mode that are managed by + * data stream lifecycle. + *

    + * API name: {@code data_streams_managed_by_dlm} + */ + public final Builder dataStreamsManagedByDlm(long value) { + this.dataStreamsManagedByDlm = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link IndexModeUsage}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public IndexModeUsage build() { + _checkSingleUse(); + + return new IndexModeUsage(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link IndexModeUsage} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + IndexModeUsage::setupIndexModeUsageDeserializer); + + protected static void setupIndexModeUsageDeserializer(ObjectDeserializer op) { + Base.setupBaseDeserializer(op); + op.add(Builder::indicesCount, JsonpDeserializer.longDeserializer(), "indices_count"); + op.add(Builder::indicesWithSyntheticSource, JsonpDeserializer.longDeserializer(), + "indices_with_synthetic_source"); + op.add(Builder::numDocs, JsonpDeserializer.longDeserializer(), "num_docs"); + op.add(Builder::sizeInBytes, JsonpDeserializer.longDeserializer(), "size_in_bytes"); + op.add(Builder::dataStreamsCount, JsonpDeserializer.longDeserializer(), "data_streams_count"); + op.add(Builder::dataStreamsManagedByIlm, JsonpDeserializer.longDeserializer(), "data_streams_managed_by_ilm"); + op.add(Builder::dataStreamsManagedByDlm, JsonpDeserializer.longDeserializer(), "data_streams_managed_by_dlm"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/usage/VectorDbColumnar.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/usage/VectorDbColumnar.java new file mode 100644 index 0000000000..586b6c98ec --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/usage/VectorDbColumnar.java @@ -0,0 +1,189 @@ +/* + * 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.xpack.usage; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +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 jakarta.json.stream.JsonGenerator; +import java.lang.Integer; +import java.lang.Long; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// 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: xpack.usage.VectorDbColumnar + +/** + * Usage statistics for indices using the vectordb_columnar index + * mode. + * + * @see API + * specification + */ +@JsonpDeserializable +public class VectorDbColumnar extends Base { + private final int indicesCount; + + private final long numDocs; + + // --------------------------------------------------------------------------------------------- + + private VectorDbColumnar(Builder builder) { + super(builder); + + this.indicesCount = ApiTypeHelper.requireNonNull(builder.indicesCount, this, "indicesCount", 0); + this.numDocs = ApiTypeHelper.requireNonNull(builder.numDocs, this, "numDocs", 0); + + } + + public static VectorDbColumnar of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The number of indices using the vectordb_columnar + * index mode. + *

    + * API name: {@code indices_count} + */ + public final int indicesCount() { + return this.indicesCount; + } + + /** + * Required - The total number of documents held across all + * vectordb_columnar indices. + *

    + * API name: {@code num_docs} + */ + public final long numDocs() { + return this.numDocs; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + generator.writeKey("indices_count"); + generator.write(this.indicesCount); + + generator.writeKey("num_docs"); + generator.write(this.numDocs); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link VectorDbColumnar}. + */ + + public static class Builder extends Base.AbstractBuilder implements ObjectBuilder { + private Integer indicesCount; + + private Long numDocs; + + public Builder() { + } + private Builder(VectorDbColumnar instance) { + this.indicesCount = instance.indicesCount; + this.numDocs = instance.numDocs; + + } + /** + * Required - The number of indices using the vectordb_columnar + * index mode. + *

    + * API name: {@code indices_count} + */ + public final Builder indicesCount(int value) { + this.indicesCount = value; + return this; + } + + /** + * Required - The total number of documents held across all + * vectordb_columnar indices. + *

    + * API name: {@code num_docs} + */ + public final Builder numDocs(long value) { + this.numDocs = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link VectorDbColumnar}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public VectorDbColumnar build() { + _checkSingleUse(); + + return new VectorDbColumnar(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link VectorDbColumnar} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + VectorDbColumnar::setupVectorDbColumnarDeserializer); + + protected static void setupVectorDbColumnarDeserializer(ObjectDeserializer op) { + Base.setupBaseDeserializer(op); + op.add(Builder::indicesCount, JsonpDeserializer.integerDeserializer(), "indices_count"); + op.add(Builder::numDocs, JsonpDeserializer.longDeserializer(), "num_docs"); + + } + +}