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 99c67a9a05..b458c37487 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 @@ -116,6 +116,7 @@ import co.elastic.clients.elasticsearch.core.UpdateRequest; import co.elastic.clients.elasticsearch.core.UpdateResponse; import co.elastic.clients.elasticsearch.dangling_indices.ElasticsearchDanglingIndicesAsyncClient; +import co.elastic.clients.elasticsearch.data_recovery.ElasticsearchDataRecoveryAsyncClient; import co.elastic.clients.elasticsearch.encryption.ElasticsearchEncryptionAsyncClient; import co.elastic.clients.elasticsearch.enrich.ElasticsearchEnrichAsyncClient; import co.elastic.clients.elasticsearch.eql.ElasticsearchEqlAsyncClient; @@ -247,6 +248,10 @@ public ElasticsearchDanglingIndicesAsyncClient danglingIndices() { return new ElasticsearchDanglingIndicesAsyncClient(this.transport, this.transportOptions); } + public ElasticsearchDataRecoveryAsyncClient dataRecovery() { + return new ElasticsearchDataRecoveryAsyncClient(this.transport, this.transportOptions); + } + public ElasticsearchEncryptionAsyncClient encryption() { return new ElasticsearchEncryptionAsyncClient(this.transport, this.transportOptions); } @@ -4243,9 +4248,13 @@ public CompletableFuture mtermvectors() { * first 10,000 hits. If you want to retrieve more hits, use PIT with * search_after. *

- * IMPORTANT: The open point in time request and each subsequent search request - * can return different identifiers; always use the most recently received ID - * for the next search request. + * IMPORTANT: Each search request against a PIT returns in its response a + * pit_id field which may be different from the identifier you + * originally supplied. Always use the most recently-received PIT identifier for + * the next request. If you make concurrent search requests against the same + * PIT, Elasticsearch can return several different pit_id values in + * its responses. In that case, use any of these values for later requests, + * preferring more recently-received values whenever possible. *

* When a PIT that contains shard failures is used in a search request, the * missing are always reported in the search response as a @@ -4313,9 +4322,13 @@ public CompletableFuture openPointInTime(OpenPointInTim * first 10,000 hits. If you want to retrieve more hits, use PIT with * search_after. *

- * IMPORTANT: The open point in time request and each subsequent search request - * can return different identifiers; always use the most recently received ID - * for the next search request. + * IMPORTANT: Each search request against a PIT returns in its response a + * pit_id field which may be different from the identifier you + * originally supplied. Always use the most recently-received PIT identifier for + * the next request. If you make concurrent search requests against the same + * PIT, Elasticsearch can return several different pit_id values in + * its responses. In that case, use any of these values for later requests, + * preferring more recently-received values whenever possible. *

* When a PIT that contains shard failures is used in a search request, the * missing are always reported in the search response as a 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 9a85b7554b..b3e2d5de2f 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 @@ -117,6 +117,7 @@ import co.elastic.clients.elasticsearch.core.UpdateRequest; import co.elastic.clients.elasticsearch.core.UpdateResponse; import co.elastic.clients.elasticsearch.dangling_indices.ElasticsearchDanglingIndicesClient; +import co.elastic.clients.elasticsearch.data_recovery.ElasticsearchDataRecoveryClient; import co.elastic.clients.elasticsearch.encryption.ElasticsearchEncryptionClient; import co.elastic.clients.elasticsearch.enrich.ElasticsearchEnrichClient; import co.elastic.clients.elasticsearch.eql.ElasticsearchEqlClient; @@ -247,6 +248,10 @@ public ElasticsearchDanglingIndicesClient danglingIndices() { return new ElasticsearchDanglingIndicesClient(this.transport, this.transportOptions); } + public ElasticsearchDataRecoveryClient dataRecovery() { + return new ElasticsearchDataRecoveryClient(this.transport, this.transportOptions); + } + public ElasticsearchEncryptionClient encryption() { return new ElasticsearchEncryptionClient(this.transport, this.transportOptions); } @@ -4273,9 +4278,13 @@ public MtermvectorsResponse mtermvectors() throws IOException, ElasticsearchExce * first 10,000 hits. If you want to retrieve more hits, use PIT with * search_after. *

- * IMPORTANT: The open point in time request and each subsequent search request - * can return different identifiers; always use the most recently received ID - * for the next search request. + * IMPORTANT: Each search request against a PIT returns in its response a + * pit_id field which may be different from the identifier you + * originally supplied. Always use the most recently-received PIT identifier for + * the next request. If you make concurrent search requests against the same + * PIT, Elasticsearch can return several different pit_id values in + * its responses. In that case, use any of these values for later requests, + * preferring more recently-received values whenever possible. *

* When a PIT that contains shard failures is used in a search request, the * missing are always reported in the search response as a @@ -4344,9 +4353,13 @@ public OpenPointInTimeResponse openPointInTime(OpenPointInTimeRequest request) * first 10,000 hits. If you want to retrieve more hits, use PIT with * search_after. *

- * IMPORTANT: The open point in time request and each subsequent search request - * can return different identifiers; always use the most recently received ID - * for the next search request. + * IMPORTANT: Each search request against a PIT returns in its response a + * pit_id field which may be different from the identifier you + * originally supplied. Always use the most recently-received PIT identifier for + * the next request. If you make concurrent search requests against the same + * PIT, Elasticsearch can return several different pit_id values in + * its responses. In that case, use any of these values for later requests, + * preferring more recently-received values whenever possible. *

* When a PIT that contains shard failures is used in a search request, the * missing are always reported in the search response as a diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ElasticsearchException.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ElasticsearchException.java index 74b927db6c..0c2c5b5d03 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ElasticsearchException.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ElasticsearchException.java @@ -58,7 +58,8 @@ private static String buildCompleteErrorMessage(String endpointId, ErrorResponse message.append("; caused by: [").append(cause.type()).append("] ").append(cause.reason()); } - // Root causes carry the actual error for generic errors such "all shards failed" + // Root causes carry the actual error for generic errors such "all shards + // failed" for (ErrorCause rootCause : error.rootCause()) { // Avoid repeating same message if (Objects.equals(rootCause.type(), error.type()) && Objects.equals(rootCause.reason(), error.reason())) { diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/KqlQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/KqlQuery.java new file mode 100644 index 0000000000..22ec6a6bf5 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/KqlQuery.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._types.query_dsl; + +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.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: _types.query_dsl.KqlQuery + +/** + * Returns documents matching a provided Kibana Query Language (KQL) expression. + * The expression is parsed and rewritten into standard Query DSL. + * + * @see API + * specification + */ +@JsonpDeserializable +public class KqlQuery extends QueryBase implements QueryVariant { + @Nullable + private final Boolean caseInsensitive; + + @Nullable + private final String defaultField; + + private final String query; + + @Nullable + private final String timeZone; + + // --------------------------------------------------------------------------------------------- + + private KqlQuery(Builder builder) { + super(builder); + + this.caseInsensitive = builder.caseInsensitive; + this.defaultField = builder.defaultField; + this.query = ApiTypeHelper.requireNonNull(builder.query, this, "query"); + this.timeZone = builder.timeZone; + + } + + public static KqlQuery of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Query variant kind. + */ + @Override + public Query.Kind _queryKind() { + return Query.Kind.Kql; + } + + /** + * If true, performs case-insensitive matching for field names and + * keyword or text terms. + *

+ * API name: {@code case_insensitive} + */ + @Nullable + public final Boolean caseInsensitive() { + return this.caseInsensitive; + } + + /** + * Default field, or field pattern with wildcards, to target when a bare term + * does not specify a field. Defaults to the + * index.query.default_field index setting, which has a default + * value of *. + *

+ * API name: {@code default_field} + */ + @Nullable + public final String defaultField() { + return this.defaultField; + } + + /** + * Required - The KQL expression to parse. + *

+ * API name: {@code query} + */ + public final String query() { + return this.query; + } + + /** + * Coordinated Universal Time (UTC) offset or IANA time zone used to interpret + * date literals in the expression. + *

+ * API name: {@code time_zone} + */ + @Nullable + public final String timeZone() { + return this.timeZone; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + if (this.caseInsensitive != null) { + generator.writeKey("case_insensitive"); + generator.write(this.caseInsensitive); + + } + if (this.defaultField != null) { + generator.writeKey("default_field"); + generator.write(this.defaultField); + + } + generator.writeKey("query"); + generator.write(this.query); + + if (this.timeZone != null) { + generator.writeKey("time_zone"); + generator.write(this.timeZone); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KqlQuery}. + */ + + public static class Builder extends QueryBase.AbstractBuilder implements ObjectBuilder { + @Nullable + private Boolean caseInsensitive; + + @Nullable + private String defaultField; + + private String query; + + @Nullable + private String timeZone; + + public Builder() { + } + private Builder(KqlQuery instance) { + this.caseInsensitive = instance.caseInsensitive; + this.defaultField = instance.defaultField; + this.query = instance.query; + this.timeZone = instance.timeZone; + + } + /** + * If true, performs case-insensitive matching for field names and + * keyword or text terms. + *

+ * API name: {@code case_insensitive} + */ + public final Builder caseInsensitive(@Nullable Boolean value) { + this.caseInsensitive = value; + return this; + } + + /** + * Default field, or field pattern with wildcards, to target when a bare term + * does not specify a field. Defaults to the + * index.query.default_field index setting, which has a default + * value of *. + *

+ * API name: {@code default_field} + */ + public final Builder defaultField(@Nullable String value) { + this.defaultField = value; + return this; + } + + /** + * Required - The KQL expression to parse. + *

+ * API name: {@code query} + */ + public final Builder query(String value) { + this.query = value; + return this; + } + + /** + * Coordinated Universal Time (UTC) offset or IANA time zone used to interpret + * date literals in the expression. + *

+ * API name: {@code time_zone} + */ + public final Builder timeZone(@Nullable String value) { + this.timeZone = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KqlQuery}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KqlQuery build() { + _checkSingleUse(); + + return new KqlQuery(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KqlQuery} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + KqlQuery::setupKqlQueryDeserializer); + + protected static void setupKqlQueryDeserializer(ObjectDeserializer op) { + QueryBase.setupQueryBaseDeserializer(op); + op.add(Builder::caseInsensitive, JsonpDeserializer.booleanDeserializer(), "case_insensitive"); + op.add(Builder::defaultField, JsonpDeserializer.stringDeserializer(), "default_field"); + op.add(Builder::query, JsonpDeserializer.stringDeserializer(), "query"); + op.add(Builder::timeZone, JsonpDeserializer.stringDeserializer(), "time_zone"); + + } + +} 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 d1f8186b59..db135901f8 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 @@ -119,6 +119,8 @@ public enum Kind implements JsonEnum { Knn("knn"), + Kql("kql"), + Match("match"), MatchAll("match_all"), @@ -602,6 +604,23 @@ public KnnQuery knn() { return TaggedUnionUtils.get(this, Kind.Knn); } + /** + * Is this variant instance of kind {@code kql}? + */ + public boolean isKql() { + return _kind == Kind.Kql; + } + + /** + * Get the {@code kql} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code kql} kind. + */ + public KqlQuery kql() { + return TaggedUnionUtils.get(this, Kind.Kql); + } + /** * Is this variant instance of kind {@code match}? */ @@ -1569,6 +1588,16 @@ public ObjectBuilder knn(Function kql(KqlQuery v) { + this._kind = Kind.Kql; + this._value = v; + return this; + } + + public ObjectBuilder kql(Function> fn) { + return this.kql(fn.apply(new KqlQuery.Builder()).build()); + } + public ObjectBuilder match(MatchQuery v) { this._kind = Kind.Match; this._value = v; @@ -2038,6 +2067,7 @@ protected static void setupQueryDeserializer(ObjectDeserializer op) { op.add(Builder::ids, IdsQuery._DESERIALIZER, "ids"); op.add(Builder::intervals, IntervalsQuery._DESERIALIZER, "intervals"); op.add(Builder::knn, KnnQuery._DESERIALIZER, "knn"); + op.add(Builder::kql, KqlQuery._DESERIALIZER, "kql"); op.add(Builder::match, MatchQuery._DESERIALIZER, "match"); op.add(Builder::matchAll, MatchAllQuery._DESERIALIZER, "match_all"); op.add(Builder::matchBoolPrefix, MatchBoolPrefixQuery._DESERIALIZER, "match_bool_prefix"); 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 3b1beb1511..7c4da70ca2 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 @@ -389,6 +389,22 @@ public static Query knn(Function> fn) return builder.build(); } + /** + * Creates a builder for the {@link KqlQuery kql} {@code Query} variant. + */ + public static KqlQuery.Builder kql() { + return new KqlQuery.Builder(); + } + + /** + * Creates a Query of the {@link KqlQuery kql} {@code Query} variant. + */ + public static Query kql(Function> fn) { + Query.Builder builder = new Query.Builder(); + builder.kql(fn.apply(new KqlQuery.Builder()).build()); + return builder.build(); + } + /** * Creates a builder for the {@link MatchQuery match} {@code Query} variant. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/CatRecoveryColumn.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/CatRecoveryColumn.java index 7631f49977..f8d4b192a5 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/CatRecoveryColumn.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/CatRecoveryColumn.java @@ -101,6 +101,22 @@ public enum CatRecoveryColumn implements JsonEnum { */ Priority("priority", "pr"), + /** + * The name of the recovery gate that blocked recovery on the target node. + *

+ * The value is n/a unless the recovery is queued in the + * created stage and blocked by a recovery gate. + */ + Gate("gate", "g"), + + /** + * The elapsed time in milliseconds recovery is blocked for. + *

+ * The value is n/a when the recovery is not blocked by a recovery + * gate. + */ + BlockedForMillis("blocked_for_millis", "bf"), + /** * The source host. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/recovery/RecoveryRecord.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/recovery/RecoveryRecord.java index c5784e6199..1081164aec 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/recovery/RecoveryRecord.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/cat/recovery/RecoveryRecord.java @@ -31,7 +31,6 @@ import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; -import java.lang.Integer; import java.lang.Long; import java.lang.String; import java.util.Objects; @@ -90,11 +89,17 @@ public class RecoveryRecord implements JsonpSerializable { private final String stage; @Nullable - private final Integer localRetries; + private final String localRetries; @Nullable private final String priority; + @Nullable + private final String gate; + + @Nullable + private final String blockedForMillis; + @Nullable private final String sourceHost; @@ -161,6 +166,8 @@ private RecoveryRecord(Builder builder) { this.stage = builder.stage; this.localRetries = builder.localRetries; this.priority = builder.priority; + this.gate = builder.gate; + this.blockedForMillis = builder.blockedForMillis; this.sourceHost = builder.sourceHost; this.sourceNode = builder.sourceNode; this.targetHost = builder.targetHost; @@ -287,7 +294,7 @@ public final String stage() { * API name: {@code local_retries} */ @Nullable - public final Integer localRetries() { + public final String localRetries() { return this.localRetries; } @@ -301,6 +308,32 @@ public final String priority() { return this.priority; } + /** + * The name of the recovery gate that blocked recovery on the target node. + *

+ * The value is n/a unless the recovery is queued in the + * created stage and blocked by a recovery gate. + *

+ * API name: {@code gate} + */ + @Nullable + public final String gate() { + return this.gate; + } + + /** + * The elapsed time in milliseconds recovery is blocked for. + *

+ * The value is n/a when the recovery is not blocked by a recovery + * gate. + *

+ * API name: {@code blocked_for_millis} + */ + @Nullable + public final String blockedForMillis() { + return this.blockedForMillis; + } + /** * The source host. *

@@ -534,6 +567,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("priority"); generator.write(this.priority); + } + if (this.gate != null) { + generator.writeKey("gate"); + generator.write(this.gate); + + } + if (this.blockedForMillis != null) { + generator.writeKey("blocked_for_millis"); + generator.write(this.blockedForMillis); + } if (this.sourceHost != null) { generator.writeKey("source_host"); @@ -663,11 +706,17 @@ public static class Builder extends WithJsonObjectBuilderBase implement private String stage; @Nullable - private Integer localRetries; + private String localRetries; @Nullable private String priority; + @Nullable + private String gate; + + @Nullable + private String blockedForMillis; + @Nullable private String sourceHost; @@ -733,6 +782,8 @@ private Builder(RecoveryRecord instance) { this.stage = instance.stage; this.localRetries = instance.localRetries; this.priority = instance.priority; + this.gate = instance.gate; + this.blockedForMillis = instance.blockedForMillis; this.sourceHost = instance.sourceHost; this.sourceNode = instance.sourceNode; this.targetHost = instance.targetHost; @@ -863,7 +914,7 @@ public final Builder stage(@Nullable String value) { *

* API name: {@code local_retries} */ - public final Builder localRetries(@Nullable Integer value) { + public final Builder localRetries(@Nullable String value) { this.localRetries = value; return this; } @@ -878,6 +929,32 @@ public final Builder priority(@Nullable String value) { return this; } + /** + * The name of the recovery gate that blocked recovery on the target node. + *

+ * The value is n/a unless the recovery is queued in the + * created stage and blocked by a recovery gate. + *

+ * API name: {@code gate} + */ + public final Builder gate(@Nullable String value) { + this.gate = value; + return this; + } + + /** + * The elapsed time in milliseconds recovery is blocked for. + *

+ * The value is n/a when the recovery is not blocked by a recovery + * gate. + *

+ * API name: {@code blocked_for_millis} + */ + public final Builder blockedForMillis(@Nullable String value) { + this.blockedForMillis = value; + return this; + } + /** * The source host. *

@@ -1091,8 +1168,10 @@ protected static void setupRecoveryRecordDeserializer(ObjectDeserializer + * IMPORTANT: Each search request against a PIT returns in its response a + * pit_id field which may be different from the identifier you + * originally supplied. Always use the most recently-received PIT identifier for + * the next request. If you make concurrent search requests against the same + * PIT, Elasticsearch can return several different pit_id values in + * its responses. In that case, use any of these values for later requests, + * preferring more recently-received values whenever possible. + *

* API name: {@code id} */ public final String id() { @@ -130,6 +138,14 @@ private Builder(ClosePointInTimeRequest instance) { /** * Required - The ID of the point-in-time. *

+ * IMPORTANT: Each search request against a PIT returns in its response a + * pit_id field which may be different from the identifier you + * originally supplied. Always use the most recently-received PIT identifier for + * the next request. If you make concurrent search requests against the same + * PIT, Elasticsearch can return several different pit_id values in + * its responses. In that case, use any of these values for later requests, + * preferring more recently-received values whenever possible. + *

* API name: {@code id} */ public final Builder id(String value) { 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 bc64e0b491..2d8dd1cf67 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 @@ -88,9 +88,13 @@ * first 10,000 hits. If you want to retrieve more hits, use PIT with * search_after. *

- * IMPORTANT: The open point in time request and each subsequent search request - * can return different identifiers; always use the most recently received ID - * for the next search request. + * IMPORTANT: Each search request against a PIT returns in its response a + * pit_id field which may be different from the identifier you + * originally supplied. Always use the most recently-received PIT identifier for + * the next request. If you make concurrent search requests against the same + * PIT, Elasticsearch can return several different pit_id values in + * its responses. In that case, use any of these values for later requests, + * preferring more recently-received values whenever possible. *

* When a PIT that contains shard failures is used in a search request, the * missing are always reported in the search response as a diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionOverdueIndex.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionOverdueIndex.java new file mode 100644 index 0000000000..4e8f9136fe --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionOverdueIndex.java @@ -0,0 +1,195 @@ +/* + * 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.health_report; + +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.health_report.DlmFrozenTransitionOverdueIndex + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DlmFrozenTransitionOverdueIndex implements JsonpSerializable { + private final String indexName; + + private final DlmFrozenTransitionState transitionState; + + // --------------------------------------------------------------------------------------------- + + private DlmFrozenTransitionOverdueIndex(Builder builder) { + + this.indexName = ApiTypeHelper.requireNonNull(builder.indexName, this, "indexName"); + this.transitionState = ApiTypeHelper.requireNonNull(builder.transitionState, this, "transitionState"); + + } + + public static DlmFrozenTransitionOverdueIndex of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code index_name} + */ + public final String indexName() { + return this.indexName; + } + + /** + * Required - API name: {@code transition_state} + */ + public final DlmFrozenTransitionState transitionState() { + return this.transitionState; + } + + /** + * 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("index_name"); + generator.write(this.indexName); + + generator.writeKey("transition_state"); + this.transitionState.serialize(generator, mapper); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DlmFrozenTransitionOverdueIndex}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String indexName; + + private DlmFrozenTransitionState transitionState; + + public Builder() { + } + private Builder(DlmFrozenTransitionOverdueIndex instance) { + this.indexName = instance.indexName; + this.transitionState = instance.transitionState; + + } + /** + * Required - API name: {@code index_name} + */ + public final Builder indexName(String value) { + this.indexName = value; + return this; + } + + /** + * Required - API name: {@code transition_state} + */ + public final Builder transitionState(DlmFrozenTransitionState value) { + this.transitionState = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DlmFrozenTransitionOverdueIndex}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DlmFrozenTransitionOverdueIndex build() { + _checkSingleUse(); + + return new DlmFrozenTransitionOverdueIndex(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DlmFrozenTransitionOverdueIndex} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DlmFrozenTransitionOverdueIndex::setupDlmFrozenTransitionOverdueIndexDeserializer); + + protected static void setupDlmFrozenTransitionOverdueIndexDeserializer( + ObjectDeserializer op) { + + op.add(Builder::indexName, JsonpDeserializer.stringDeserializer(), "index_name"); + op.add(Builder::transitionState, DlmFrozenTransitionState._DESERIALIZER, "transition_state"); + + } + +} 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 new file mode 100644 index 0000000000..82c0d95416 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionState.java @@ -0,0 +1,71 @@ +/* + * 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.health_report; + +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 DlmFrozenTransitionState implements JsonEnum { + Unmarked("unmarked"), + + Marked("marked"), + + Queued("queued"), + + Running("running"), + + ; + + private final String jsonValue; + + DlmFrozenTransitionState(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + DlmFrozenTransitionState.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionsIndicator.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionsIndicator.java new file mode 100644 index 0000000000..8a9a4fa1d3 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionsIndicator.java @@ -0,0 +1,167 @@ +/* + * 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.health_report; + +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: _global.health_report.DlmFrozenTransitionsIndicator + +/** + * DLM_FROZEN_TRANSITIONS + * + * @see API + * specification + */ +@JsonpDeserializable +public class DlmFrozenTransitionsIndicator extends BaseIndicator { + @Nullable + private final DlmFrozenTransitionsIndicatorDetails details; + + // --------------------------------------------------------------------------------------------- + + private DlmFrozenTransitionsIndicator(Builder builder) { + super(builder); + + this.details = builder.details; + + } + + public static DlmFrozenTransitionsIndicator of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code details} + */ + @Nullable + public final DlmFrozenTransitionsIndicatorDetails details() { + return this.details; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + if (this.details != null) { + generator.writeKey("details"); + this.details.serialize(generator, mapper); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DlmFrozenTransitionsIndicator}. + */ + + public static class Builder extends BaseIndicator.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private DlmFrozenTransitionsIndicatorDetails details; + + public Builder() { + } + private Builder(DlmFrozenTransitionsIndicator instance) { + this.details = instance.details; + + } + /** + * API name: {@code details} + */ + public final Builder details(@Nullable DlmFrozenTransitionsIndicatorDetails value) { + this.details = value; + return this; + } + + /** + * API name: {@code details} + */ + public final Builder details( + Function> fn) { + return this.details(fn.apply(new DlmFrozenTransitionsIndicatorDetails.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DlmFrozenTransitionsIndicator}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DlmFrozenTransitionsIndicator build() { + _checkSingleUse(); + + return new DlmFrozenTransitionsIndicator(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DlmFrozenTransitionsIndicator} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DlmFrozenTransitionsIndicator::setupDlmFrozenTransitionsIndicatorDeserializer); + + protected static void setupDlmFrozenTransitionsIndicatorDeserializer( + ObjectDeserializer op) { + BaseIndicator.setupBaseIndicatorDeserializer(op); + op.add(Builder::details, DlmFrozenTransitionsIndicatorDetails._DESERIALIZER, "details"); + + } + +} 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 new file mode 100644 index 0000000000..02034db73b --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/health_report/DlmFrozenTransitionsIndicatorDetails.java @@ -0,0 +1,415 @@ +/* + * 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.health_report; + +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.Integer; +import java.lang.Long; +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.health_report.DlmFrozenTransitionsIndicatorDetails + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DlmFrozenTransitionsIndicatorDetails implements JsonpSerializable { + @Nullable + private final Boolean transitionsEnabled; + + @Nullable + private final Boolean serviceRunning; + + @Nullable + private final Boolean defaultRepositoryConfigured; + + @Nullable + private final Integer overdueIndicesCount; + + private final Map overdueIndicesCountByState; + + private final List overdueIndicesSample; + + @Nullable + private final Long generatedAtMillis; + + // --------------------------------------------------------------------------------------------- + + private DlmFrozenTransitionsIndicatorDetails(Builder builder) { + + this.transitionsEnabled = builder.transitionsEnabled; + this.serviceRunning = builder.serviceRunning; + this.defaultRepositoryConfigured = builder.defaultRepositoryConfigured; + this.overdueIndicesCount = builder.overdueIndicesCount; + this.overdueIndicesCountByState = ApiTypeHelper.unmodifiable(builder.overdueIndicesCountByState); + this.overdueIndicesSample = ApiTypeHelper.unmodifiable(builder.overdueIndicesSample); + this.generatedAtMillis = builder.generatedAtMillis; + + } + + public static DlmFrozenTransitionsIndicatorDetails of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code transitions_enabled} + */ + @Nullable + public final Boolean transitionsEnabled() { + return this.transitionsEnabled; + } + + /** + * API name: {@code service_running} + */ + @Nullable + public final Boolean serviceRunning() { + return this.serviceRunning; + } + + /** + * API name: {@code default_repository_configured} + */ + @Nullable + public final Boolean defaultRepositoryConfigured() { + return this.defaultRepositoryConfigured; + } + + /** + * API name: {@code overdue_indices_count} + */ + @Nullable + public final Integer overdueIndicesCount() { + return this.overdueIndicesCount; + } + + /** + * API name: {@code overdue_indices_count_by_state} + */ + public final Map overdueIndicesCountByState() { + return this.overdueIndicesCountByState; + } + + /** + * API name: {@code overdue_indices_sample} + */ + public final List overdueIndicesSample() { + return this.overdueIndicesSample; + } + + /** + * Only present when the indicator status is unknown, meaning the + * health snapshot is stale. + *

+ * API name: {@code generated_at_millis} + */ + @Nullable + public final Long generatedAtMillis() { + return this.generatedAtMillis; + } + + /** + * 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.transitionsEnabled != null) { + generator.writeKey("transitions_enabled"); + generator.write(this.transitionsEnabled); + + } + if (this.serviceRunning != null) { + generator.writeKey("service_running"); + generator.write(this.serviceRunning); + + } + if (this.defaultRepositoryConfigured != null) { + generator.writeKey("default_repository_configured"); + generator.write(this.defaultRepositoryConfigured); + + } + if (this.overdueIndicesCount != null) { + generator.writeKey("overdue_indices_count"); + generator.write(this.overdueIndicesCount); + + } + if (ApiTypeHelper.isDefined(this.overdueIndicesCountByState)) { + generator.writeKey("overdue_indices_count_by_state"); + generator.writeStartObject(); + for (Map.Entry item0 : this.overdueIndicesCountByState.entrySet()) { + generator.writeKey(item0.getKey().jsonValue()); + generator.write(item0.getValue()); + + } + generator.writeEnd(); + + } + if (ApiTypeHelper.isDefined(this.overdueIndicesSample)) { + generator.writeKey("overdue_indices_sample"); + generator.writeStartArray(); + for (DlmFrozenTransitionOverdueIndex item0 : this.overdueIndicesSample) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (this.generatedAtMillis != null) { + generator.writeKey("generated_at_millis"); + generator.write(this.generatedAtMillis); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DlmFrozenTransitionsIndicatorDetails}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private Boolean transitionsEnabled; + + @Nullable + private Boolean serviceRunning; + + @Nullable + private Boolean defaultRepositoryConfigured; + + @Nullable + private Integer overdueIndicesCount; + + @Nullable + private Map overdueIndicesCountByState; + + @Nullable + private List overdueIndicesSample; + + @Nullable + private Long generatedAtMillis; + + public Builder() { + } + private Builder(DlmFrozenTransitionsIndicatorDetails instance) { + this.transitionsEnabled = instance.transitionsEnabled; + this.serviceRunning = instance.serviceRunning; + this.defaultRepositoryConfigured = instance.defaultRepositoryConfigured; + this.overdueIndicesCount = instance.overdueIndicesCount; + this.overdueIndicesCountByState = instance.overdueIndicesCountByState; + this.overdueIndicesSample = instance.overdueIndicesSample; + this.generatedAtMillis = instance.generatedAtMillis; + + } + /** + * API name: {@code transitions_enabled} + */ + public final Builder transitionsEnabled(@Nullable Boolean value) { + this.transitionsEnabled = value; + return this; + } + + /** + * API name: {@code service_running} + */ + public final Builder serviceRunning(@Nullable Boolean value) { + this.serviceRunning = value; + return this; + } + + /** + * API name: {@code default_repository_configured} + */ + public final Builder defaultRepositoryConfigured(@Nullable Boolean value) { + this.defaultRepositoryConfigured = value; + return this; + } + + /** + * API name: {@code overdue_indices_count} + */ + public final Builder overdueIndicesCount(@Nullable Integer value) { + this.overdueIndicesCount = value; + return this; + } + + /** + * API name: {@code overdue_indices_count_by_state} + *

+ * Adds all entries of map to + * overdueIndicesCountByState. + */ + public final Builder overdueIndicesCountByState(Map map) { + this.overdueIndicesCountByState = _mapPutAll(this.overdueIndicesCountByState, map); + return this; + } + + /** + * API name: {@code overdue_indices_count_by_state} + *

+ * Adds an entry to overdueIndicesCountByState. + */ + public final Builder overdueIndicesCountByState(DlmFrozenTransitionState key, Integer value) { + this.overdueIndicesCountByState = _mapPut(this.overdueIndicesCountByState, key, value); + return this; + } + + /** + * API name: {@code overdue_indices_sample} + *

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

+ * Adds one or more values to overdueIndicesSample. + */ + public final Builder overdueIndicesSample(DlmFrozenTransitionOverdueIndex value, + DlmFrozenTransitionOverdueIndex... values) { + this.overdueIndicesSample = _listAdd(this.overdueIndicesSample, value, values); + return this; + } + + /** + * API name: {@code overdue_indices_sample} + *

+ * Adds a value to overdueIndicesSample using a builder lambda. + */ + public final Builder overdueIndicesSample( + Function> fn) { + return overdueIndicesSample(fn.apply(new DlmFrozenTransitionOverdueIndex.Builder()).build()); + } + + /** + * Only present when the indicator status is unknown, meaning the + * health snapshot is stale. + *

+ * API name: {@code generated_at_millis} + */ + public final Builder generatedAtMillis(@Nullable Long value) { + this.generatedAtMillis = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DlmFrozenTransitionsIndicatorDetails}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DlmFrozenTransitionsIndicatorDetails build() { + _checkSingleUse(); + + return new DlmFrozenTransitionsIndicatorDetails(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DlmFrozenTransitionsIndicatorDetails} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + DlmFrozenTransitionsIndicatorDetails::setupDlmFrozenTransitionsIndicatorDetailsDeserializer); + + protected static void setupDlmFrozenTransitionsIndicatorDetailsDeserializer( + ObjectDeserializer op) { + + op.add(Builder::transitionsEnabled, JsonpDeserializer.booleanDeserializer(), "transitions_enabled"); + op.add(Builder::serviceRunning, JsonpDeserializer.booleanDeserializer(), "service_running"); + op.add(Builder::defaultRepositoryConfigured, JsonpDeserializer.booleanDeserializer(), + "default_repository_configured"); + op.add(Builder::overdueIndicesCount, JsonpDeserializer.integerDeserializer(), "overdue_indices_count"); + op.add(Builder::overdueIndicesCountByState, JsonpDeserializer + .enumMapDeserializer(DlmFrozenTransitionState._DESERIALIZER, JsonpDeserializer.integerDeserializer()), + "overdue_indices_count_by_state"); + op.add(Builder::overdueIndicesSample, + JsonpDeserializer.arrayDeserializer(DlmFrozenTransitionOverdueIndex._DESERIALIZER), + "overdue_indices_sample"); + op.add(Builder::generatedAtMillis, JsonpDeserializer.longDeserializer(), "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 c5b2672450..7b73fba211 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 @@ -88,6 +88,9 @@ public class Indicators implements JsonpSerializable { @Nullable private final ProjectEncryptionKeyIndicator projectEncryptionKey; + @Nullable + private final DlmFrozenTransitionsIndicator dlmFrozenTransitions; + // --------------------------------------------------------------------------------------------- private Indicators(Builder builder) { @@ -102,6 +105,7 @@ private Indicators(Builder builder) { this.shardsCapacity = builder.shardsCapacity; this.fileSettings = builder.fileSettings; this.projectEncryptionKey = builder.projectEncryptionKey; + this.dlmFrozenTransitions = builder.dlmFrozenTransitions; } @@ -189,6 +193,14 @@ public final ProjectEncryptionKeyIndicator projectEncryptionKey() { return this.projectEncryptionKey; } + /** + * API name: {@code dlm_frozen_transitions} + */ + @Nullable + public final DlmFrozenTransitionsIndicator dlmFrozenTransitions() { + return this.dlmFrozenTransitions; + } + /** * Serialize this object to JSON. */ @@ -250,6 +262,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.projectEncryptionKey.serialize(generator, mapper); } + if (this.dlmFrozenTransitions != null) { + generator.writeKey("dlm_frozen_transitions"); + this.dlmFrozenTransitions.serialize(generator, mapper); + + } } @@ -295,6 +312,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private ProjectEncryptionKeyIndicator projectEncryptionKey; + @Nullable + private DlmFrozenTransitionsIndicator dlmFrozenTransitions; + public Builder() { } private Builder(Indicators instance) { @@ -308,6 +328,7 @@ private Builder(Indicators instance) { this.shardsCapacity = instance.shardsCapacity; this.fileSettings = instance.fileSettings; this.projectEncryptionKey = instance.projectEncryptionKey; + this.dlmFrozenTransitions = instance.dlmFrozenTransitions; } /** @@ -467,6 +488,22 @@ public final Builder projectEncryptionKey( return this.projectEncryptionKey(fn.apply(new ProjectEncryptionKeyIndicator.Builder()).build()); } + /** + * API name: {@code dlm_frozen_transitions} + */ + public final Builder dlmFrozenTransitions(@Nullable DlmFrozenTransitionsIndicator value) { + this.dlmFrozenTransitions = value; + return this; + } + + /** + * API name: {@code dlm_frozen_transitions} + */ + public final Builder dlmFrozenTransitions( + Function> fn) { + return this.dlmFrozenTransitions(fn.apply(new DlmFrozenTransitionsIndicator.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -511,6 +548,7 @@ protected static void setupIndicatorsDeserializer(ObjectDeserializer + * IMPORTANT: Each search request against a PIT returns in its response a + * pit_id field which may be different from the identifier you + * originally supplied. Always use the most recently-received PIT identifier for + * the next request. If you make concurrent search requests against the same + * PIT, Elasticsearch can return several different pit_id values in + * its responses. In that case, use any of these values for later requests, + * preferring more recently-received values whenever possible. + *

* API name: {@code pit_id} */ @Nullable @@ -568,6 +578,16 @@ public final BuilderT profile(Function> } /** + * An updated identifier for the point-in-time that was searched. + *

+ * IMPORTANT: Each search request against a PIT returns in its response a + * pit_id field which may be different from the identifier you + * originally supplied. Always use the most recently-received PIT identifier for + * the next request. If you make concurrent search requests against the same + * PIT, Elasticsearch can return several different pit_id values in + * its responses. In that case, use any of these values for later requests, + * preferring more recently-received values whenever possible. + *

* API name: {@code pit_id} */ public final BuilderT pitId(@Nullable String value) { diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ElasticsearchDataRecoveryAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ElasticsearchDataRecoveryAsyncClient.java new file mode 100644 index 0000000000..1a7f314776 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ElasticsearchDataRecoveryAsyncClient.java @@ -0,0 +1,125 @@ +/* + * 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.ApiClient; +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.transport.ElasticsearchTransport; +import co.elastic.clients.transport.Endpoint; +import co.elastic.clients.transport.JsonEndpoint; +import co.elastic.clients.transport.Transport; +import co.elastic.clients.transport.TransportOptions; +import co.elastic.clients.util.ObjectBuilder; +import java.util.concurrent.CompletableFuture; +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. +// +//---------------------------------------------------------------- + +/** + * Client for the data_recovery namespace. + */ +public class ElasticsearchDataRecoveryAsyncClient + extends + ApiClient { + + public ElasticsearchDataRecoveryAsyncClient(ElasticsearchTransport transport) { + super(transport, null); + } + + public ElasticsearchDataRecoveryAsyncClient(ElasticsearchTransport transport, + @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public ElasticsearchDataRecoveryAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new ElasticsearchDataRecoveryAsyncClient(this.transport, transportOptions); + } + + // ----- Endpoint: data_recovery.get_recovery_points + + /** + * Get recovery points. + *

+ * Get recovery points from the platform-managed data recovery repository. This + * API is intended for internal operator use. Recovery points are returned in + * descending order by end time. Repository, snapshot, and policy identifiers + * are not exposed. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture getRecoveryPoints(GetRecoveryPointsRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) GetRecoveryPointsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Get recovery points. + *

+ * Get recovery points from the platform-managed data recovery repository. This + * API is intended for internal operator use. Recovery points are returned in + * descending order by end time. Repository, snapshot, and policy identifiers + * are not exposed. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRecoveryPointsRequest} + * @see Documentation on elastic.co + */ + + public final CompletableFuture getRecoveryPoints( + Function> fn) { + return getRecoveryPoints(fn.apply(new GetRecoveryPointsRequest.Builder()).build()); + } + + /** + * Get recovery points. + *

+ * Get recovery points from the platform-managed data recovery repository. This + * API is intended for internal operator use. Recovery points are returned in + * descending order by end time. Repository, snapshot, and policy identifiers + * are not exposed. + * + * @see Documentation on elastic.co + */ + + public CompletableFuture getRecoveryPoints() { + return this.transport.performRequestAsync(new GetRecoveryPointsRequest.Builder().build(), + GetRecoveryPointsRequest._ENDPOINT, this.transportOptions); + } + +} 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 new file mode 100644 index 0000000000..ac5310a608 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/ElasticsearchDataRecoveryClient.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.data_recovery; + +import co.elastic.clients.ApiClient; +import co.elastic.clients.elasticsearch._types.ElasticsearchException; +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.transport.ElasticsearchTransport; +import co.elastic.clients.transport.Endpoint; +import co.elastic.clients.transport.JsonEndpoint; +import co.elastic.clients.transport.Transport; +import co.elastic.clients.transport.TransportOptions; +import co.elastic.clients.util.ObjectBuilder; +import java.io.IOException; +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. +// +//---------------------------------------------------------------- + +/** + * Client for the data_recovery namespace. + */ +public class ElasticsearchDataRecoveryClient + extends + ApiClient { + + public ElasticsearchDataRecoveryClient(ElasticsearchTransport transport) { + super(transport, null); + } + + public ElasticsearchDataRecoveryClient(ElasticsearchTransport transport, + @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public ElasticsearchDataRecoveryClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new ElasticsearchDataRecoveryClient(this.transport, transportOptions); + } + + // ----- Endpoint: data_recovery.get_recovery_points + + /** + * Get recovery points. + *

+ * Get recovery points from the platform-managed data recovery repository. This + * API is intended for internal operator use. Recovery points are returned in + * descending order by end time. Repository, snapshot, and policy identifiers + * are not exposed. + * + * @see Documentation on elastic.co + */ + + public GetRecoveryPointsResponse getRecoveryPoints(GetRecoveryPointsRequest request) + throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) GetRecoveryPointsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Get recovery points. + *

+ * Get recovery points from the platform-managed data recovery repository. This + * API is intended for internal operator use. Recovery points are returned in + * descending order by end time. Repository, snapshot, and policy identifiers + * are not exposed. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRecoveryPointsRequest} + * @see Documentation on elastic.co + */ + + public final GetRecoveryPointsResponse getRecoveryPoints( + Function> fn) + throws IOException, ElasticsearchException { + return getRecoveryPoints(fn.apply(new GetRecoveryPointsRequest.Builder()).build()); + } + + /** + * Get recovery points. + *

+ * Get recovery points from the platform-managed data recovery repository. This + * API is intended for internal operator use. Recovery points are returned in + * descending order by end time. Repository, snapshot, and policy identifiers + * are not exposed. + * + * @see Documentation on elastic.co + */ + + public GetRecoveryPointsResponse getRecoveryPoints() throws IOException, ElasticsearchException { + return this.transport.performRequest(new GetRecoveryPointsRequest.Builder().build(), + GetRecoveryPointsRequest._ENDPOINT, this.transportOptions); + } + +} 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 new file mode 100644 index 0000000000..58407f2706 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsRequest.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.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.lang.Integer; +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_points.Request + +/** + * Get recovery points. + *

+ * Get recovery points from the platform-managed data recovery repository. This + * API is intended for internal operator use. Recovery points are returned in + * descending order by end time. Repository, snapshot, and policy identifiers + * are not exposed. + * + * @see API + * specification + */ + +public class GetRecoveryPointsRequest extends RequestBase { + @Nullable + private final DateTime endTimeBefore; + + @Nullable + private final Time masterTimeout; + + @Nullable + private final Integer size; + + // --------------------------------------------------------------------------------------------- + + private GetRecoveryPointsRequest(Builder builder) { + + this.endTimeBefore = builder.endTimeBefore; + this.masterTimeout = builder.masterTimeout; + this.size = builder.size; + + } + + public static GetRecoveryPointsRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Return only recovery points whose end time is earlier than this value. The + * boundary is exclusive and can be set to the last recovery point's end time to + * retrieve the next page. + *

+ * API name: {@code end_time_before} + */ + @Nullable + public final DateTime endTimeBefore() { + return this.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. + *

+ * API name: {@code master_timeout} + */ + @Nullable + public final Time masterTimeout() { + return this.masterTimeout; + } + + /** + * The maximum number of recovery points 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 GetRecoveryPointsRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private DateTime endTimeBefore; + + @Nullable + private Time masterTimeout; + + @Nullable + private Integer size; + + public Builder() { + } + private Builder(GetRecoveryPointsRequest instance) { + this.endTimeBefore = instance.endTimeBefore; + this.masterTimeout = instance.masterTimeout; + this.size = instance.size; + + } + /** + * Return only recovery points whose end time is earlier than this value. The + * boundary is exclusive and can be set to the last recovery point's end time to + * retrieve the next page. + *

+ * API name: {@code end_time_before} + */ + public final Builder endTimeBefore(@Nullable DateTime value) { + this.endTimeBefore = value; + return this; + } + + /** + * 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. + *

+ * API name: {@code master_timeout} + */ + public final Builder masterTimeout(@Nullable Time value) { + this.masterTimeout = value; + return this; + } + + /** + * 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. + *

+ * API name: {@code master_timeout} + */ + public final Builder masterTimeout(Function> fn) { + return this.masterTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * The maximum number of recovery points 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 GetRecoveryPointsRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GetRecoveryPointsRequest build() { + _checkSingleUse(); + + return new GetRecoveryPointsRequest(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_points}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/data_recovery.get_recovery_points", + + // Request method + request -> { + return "GET"; + + }, + + // Request path + request -> { + return "/_data_recovery/points"; + + }, + + // Path parameters + request -> { + return Collections.emptyMap(); + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.endTimeBefore != null) { + params.put("end_time_before", request.endTimeBefore.toString()); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } + if (request.size != null) { + params.put("size", String.valueOf(request.size)); + } + return params; + + }, SimpleEndpoint.emptyMap(), false, GetRecoveryPointsResponse._DESERIALIZER); +} 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 new file mode 100644 index 0000000000..4f9e7185c3 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/GetRecoveryPointsResponse.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.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; +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: data_recovery.get_recovery_points.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class GetRecoveryPointsResponse implements JsonpSerializable { + private final List recoveryPoints; + + // --------------------------------------------------------------------------------------------- + + private GetRecoveryPointsResponse(Builder builder) { + + this.recoveryPoints = ApiTypeHelper.unmodifiableRequired(builder.recoveryPoints, this, "recoveryPoints"); + + } + + public static GetRecoveryPointsResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - Recovery points in descending order by end time. + *

+ * API name: {@code recovery_points} + */ + public final List recoveryPoints() { + return this.recoveryPoints; + } + + /** + * 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.recoveryPoints)) { + generator.writeKey("recovery_points"); + generator.writeStartArray(); + for (RecoveryPoint item0 : this.recoveryPoints) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GetRecoveryPointsResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private List recoveryPoints; + + /** + * Required - Recovery points in descending order by end time. + *

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

+ * Adds all elements of list to recoveryPoints. + */ + public final Builder recoveryPoints(List list) { + this.recoveryPoints = _listAddAll(this.recoveryPoints, list); + return this; + } + + /** + * Required - Recovery points in descending order by end time. + *

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

+ * Adds one or more values to recoveryPoints. + */ + public final Builder recoveryPoints(RecoveryPoint value, RecoveryPoint... values) { + this.recoveryPoints = _listAdd(this.recoveryPoints, value, values); + return this; + } + + /** + * Required - Recovery points in descending order by end time. + *

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

+ * Adds a value to recoveryPoints using a builder lambda. + */ + public final Builder recoveryPoints(Function> fn) { + return recoveryPoints(fn.apply(new RecoveryPoint.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GetRecoveryPointsResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GetRecoveryPointsResponse build() { + _checkSingleUse(); + + return new GetRecoveryPointsResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GetRecoveryPointsResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, GetRecoveryPointsResponse::setupGetRecoveryPointsResponseDeserializer); + + protected static void setupGetRecoveryPointsResponseDeserializer( + ObjectDeserializer op) { + + op.add(Builder::recoveryPoints, JsonpDeserializer.arrayDeserializer(RecoveryPoint._DESERIALIZER), + "recovery_points"); + + } + +} 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/get_recovery_points/RecoveryPoint.java new file mode 100644 index 0000000000..046e8b2af7 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/data_recovery/get_recovery_points/RecoveryPoint.java @@ -0,0 +1,198 @@ +/* + * 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_points; + +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.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_points.RecoveryPoint + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class RecoveryPoint implements JsonpSerializable { + private final DateTime startTime; + + private final DateTime endTime; + + // --------------------------------------------------------------------------------------------- + + private RecoveryPoint(Builder builder) { + + this.startTime = ApiTypeHelper.requireNonNull(builder.startTime, this, "startTime"); + this.endTime = ApiTypeHelper.requireNonNull(builder.endTime, this, "endTime"); + + } + + public static RecoveryPoint of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The time when creation of the recovery point started. + *

+ * API name: {@code start_time} + */ + public final DateTime startTime() { + return this.startTime; + } + + /** + * Required - The time when creation of the recovery point completed. + *

+ * API name: {@code end_time} + */ + public final DateTime endTime() { + return this.endTime; + } + + /** + * 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_time"); + this.startTime.serialize(generator, mapper); + generator.writeKey("end_time"); + this.endTime.serialize(generator, mapper); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RecoveryPoint}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + private DateTime startTime; + + private DateTime endTime; + + public Builder() { + } + private Builder(RecoveryPoint instance) { + this.startTime = instance.startTime; + this.endTime = instance.endTime; + + } + /** + * Required - The time when creation of the recovery point started. + *

+ * API name: {@code start_time} + */ + public final Builder startTime(DateTime value) { + this.startTime = value; + return this; + } + + /** + * Required - The time when creation of the recovery point completed. + *

+ * API name: {@code end_time} + */ + public final Builder endTime(DateTime value) { + this.endTime = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link RecoveryPoint}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RecoveryPoint build() { + _checkSingleUse(); + + return new RecoveryPoint(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RecoveryPoint} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + RecoveryPoint::setupRecoveryPointDeserializer); + + protected static void setupRecoveryPointDeserializer(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/doc-files/api-spec.html b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html index 0e1d7d3ed4..3d97d135e7 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 @@ -21,7 +21,7 @@ '_global.cancel_reindex.Response': '_global/cancel_reindex/CancelReindexResponse.ts#L31-L87', '_global.clear_scroll.Request': '_global/clear_scroll/ClearScrollRequest.ts#L23-L64', '_global.clear_scroll.Response': '_global/clear_scroll/ClearScrollResponse.ts#L22-L43', -'_global.close_point_in_time.Request': '_global/close_point_in_time/ClosePointInTimeRequest.ts#L23-L51', +'_global.close_point_in_time.Request': '_global/close_point_in_time/ClosePointInTimeRequest.ts#L23-L56', '_global.close_point_in_time.Response': '_global/close_point_in_time/ClosePointInTimeResponse.ts#L22-L42', '_global.count.Request': '_global/count/CountRequest.ts#L32-L194', '_global.count.Response': '_global/count/CountResponse.ts#L23-L25', @@ -61,41 +61,45 @@ '_global.get_script_languages.Response': '_global/get_script_languages/GetScriptLanguagesResponse.ts#L22-L27', '_global.get_source.Request': '_global/get_source/SourceRequest.ts#L32-L114', '_global.get_source.Response': '_global/get_source/SourceResponse.ts#L20-L23', -'_global.health_report.BaseIndicator': '_global/health_report/types.ts#L46-L51', -'_global.health_report.DataStreamLifecycleDetails': '_global/health_report/types.ts#L155-L159', -'_global.health_report.DataStreamLifecycleIndicator': '_global/health_report/types.ts#L150-L154', -'_global.health_report.Diagnosis': '_global/health_report/types.ts#L53-L59', -'_global.health_report.DiagnosisAffectedResources': '_global/health_report/types.ts#L61-L67', -'_global.health_report.DiskIndicator': '_global/health_report/types.ts#L126-L130', -'_global.health_report.DiskIndicatorDetails': '_global/health_report/types.ts#L131-L137', -'_global.health_report.FileSettingsIndicator': '_global/health_report/types.ts#L209-L213', -'_global.health_report.FileSettingsIndicatorDetails': '_global/health_report/types.ts#L215-L218', -'_global.health_report.IlmIndicator': '_global/health_report/types.ts#L166-L170', -'_global.health_report.IlmIndicatorDetails': '_global/health_report/types.ts#L171-L175', -'_global.health_report.Impact': '_global/health_report/types.ts#L69-L74', -'_global.health_report.ImpactArea': '_global/health_report/types.ts#L76-L81', +'_global.health_report.BaseIndicator': '_global/health_report/types.ts#L48-L53', +'_global.health_report.DataStreamLifecycleDetails': '_global/health_report/types.ts#L157-L161', +'_global.health_report.DataStreamLifecycleIndicator': '_global/health_report/types.ts#L152-L156', +'_global.health_report.Diagnosis': '_global/health_report/types.ts#L55-L61', +'_global.health_report.DiagnosisAffectedResources': '_global/health_report/types.ts#L63-L69', +'_global.health_report.DiskIndicator': '_global/health_report/types.ts#L128-L132', +'_global.health_report.DiskIndicatorDetails': '_global/health_report/types.ts#L133-L139', +'_global.health_report.DlmFrozenTransitionOverdueIndex': '_global/health_report/types.ts#L265-L268', +'_global.health_report.DlmFrozenTransitionState': '_global/health_report/types.ts#L258-L263', +'_global.health_report.DlmFrozenTransitionsIndicator': '_global/health_report/types.ts#L241-L245', +'_global.health_report.DlmFrozenTransitionsIndicatorDetails': '_global/health_report/types.ts#L247-L256', +'_global.health_report.FileSettingsIndicator': '_global/health_report/types.ts#L211-L215', +'_global.health_report.FileSettingsIndicatorDetails': '_global/health_report/types.ts#L217-L220', +'_global.health_report.IlmIndicator': '_global/health_report/types.ts#L168-L172', +'_global.health_report.IlmIndicatorDetails': '_global/health_report/types.ts#L173-L177', +'_global.health_report.Impact': '_global/health_report/types.ts#L71-L76', +'_global.health_report.ImpactArea': '_global/health_report/types.ts#L78-L83', '_global.health_report.IndicatorHealthStatus': '_global/health_report/types.ts#L25-L31', -'_global.health_report.IndicatorNode': '_global/health_report/types.ts#L94-L97', -'_global.health_report.Indicators': '_global/health_report/types.ts#L33-L44', -'_global.health_report.MasterIsStableIndicator': '_global/health_report/types.ts#L83-L87', -'_global.health_report.MasterIsStableIndicatorClusterFormationNode': '_global/health_report/types.ts#L102-L106', -'_global.health_report.MasterIsStableIndicatorDetails': '_global/health_report/types.ts#L88-L93', -'_global.health_report.MasterIsStableIndicatorExceptionFetchingHistory': '_global/health_report/types.ts#L98-L101', -'_global.health_report.ProjectEncryptionKeyDetails': '_global/health_report/types.ts#L226-L237', -'_global.health_report.ProjectEncryptionKeyIndicator': '_global/health_report/types.ts#L220-L224', -'_global.health_report.RepositoryIntegrityIndicator': '_global/health_report/types.ts#L139-L143', -'_global.health_report.RepositoryIntegrityIndicatorDetails': '_global/health_report/types.ts#L144-L148', +'_global.health_report.IndicatorNode': '_global/health_report/types.ts#L96-L99', +'_global.health_report.Indicators': '_global/health_report/types.ts#L33-L46', +'_global.health_report.MasterIsStableIndicator': '_global/health_report/types.ts#L85-L89', +'_global.health_report.MasterIsStableIndicatorClusterFormationNode': '_global/health_report/types.ts#L104-L108', +'_global.health_report.MasterIsStableIndicatorDetails': '_global/health_report/types.ts#L90-L95', +'_global.health_report.MasterIsStableIndicatorExceptionFetchingHistory': '_global/health_report/types.ts#L100-L103', +'_global.health_report.ProjectEncryptionKeyDetails': '_global/health_report/types.ts#L228-L239', +'_global.health_report.ProjectEncryptionKeyIndicator': '_global/health_report/types.ts#L222-L226', +'_global.health_report.RepositoryIntegrityIndicator': '_global/health_report/types.ts#L141-L145', +'_global.health_report.RepositoryIntegrityIndicatorDetails': '_global/health_report/types.ts#L146-L150', '_global.health_report.Request': '_global/health_report/Request.ts#L25-L84', '_global.health_report.Response': '_global/health_report/Response.ts#L22-L28', -'_global.health_report.ShardsAvailabilityIndicator': '_global/health_report/types.ts#L108-L112', -'_global.health_report.ShardsAvailabilityIndicatorDetails': '_global/health_report/types.ts#L113-L124', -'_global.health_report.ShardsCapacityIndicator': '_global/health_report/types.ts#L193-L197', -'_global.health_report.ShardsCapacityIndicatorDetails': '_global/health_report/types.ts#L199-L202', -'_global.health_report.ShardsCapacityIndicatorTierDetail': '_global/health_report/types.ts#L204-L207', -'_global.health_report.SlmIndicator': '_global/health_report/types.ts#L177-L181', -'_global.health_report.SlmIndicatorDetails': '_global/health_report/types.ts#L182-L186', -'_global.health_report.SlmIndicatorUnhealthyPolicies': '_global/health_report/types.ts#L188-L191', -'_global.health_report.StagnatingBackingIndices': '_global/health_report/types.ts#L160-L164', +'_global.health_report.ShardsAvailabilityIndicator': '_global/health_report/types.ts#L110-L114', +'_global.health_report.ShardsAvailabilityIndicatorDetails': '_global/health_report/types.ts#L115-L126', +'_global.health_report.ShardsCapacityIndicator': '_global/health_report/types.ts#L195-L199', +'_global.health_report.ShardsCapacityIndicatorDetails': '_global/health_report/types.ts#L201-L204', +'_global.health_report.ShardsCapacityIndicatorTierDetail': '_global/health_report/types.ts#L206-L209', +'_global.health_report.SlmIndicator': '_global/health_report/types.ts#L179-L183', +'_global.health_report.SlmIndicatorDetails': '_global/health_report/types.ts#L184-L188', +'_global.health_report.SlmIndicatorUnhealthyPolicies': '_global/health_report/types.ts#L190-L193', +'_global.health_report.StagnatingBackingIndices': '_global/health_report/types.ts#L162-L166', '_global.index.Request': '_global/index/IndexRequest.ts#L36-L290', '_global.index.Response': '_global/index/IndexResponse.ts#L22-L25', '_global.info.Request': '_global/info/RootNodeInfoRequest.ts#L23-L44', @@ -120,7 +124,7 @@ '_global.mtermvectors.Request': '_global/mtermvectors/MultiTermVectorsRequest.ts#L32-L149', '_global.mtermvectors.Response': '_global/mtermvectors/MultiTermVectorsResponse.ts#L22-L24', '_global.mtermvectors.TermVectorsResult': '_global/mtermvectors/types.ts#L96-L104', -'_global.open_point_in_time.Request': '_global/open_point_in_time/OpenPointInTimeRequest.ts#L32-L153', +'_global.open_point_in_time.Request': '_global/open_point_in_time/OpenPointInTimeRequest.ts#L32-L156', '_global.open_point_in_time.Response': '_global/open_point_in_time/OpenPointInTimeResponse.ts#L23-L35', '_global.ping.Request': '_global/ping/PingRequest.ts#L23-L41', '_global.put_script.Request': '_global/put_script/PutScriptRequest.ts#L25-L90', @@ -164,7 +168,7 @@ '_global.scroll.Response': '_global/scroll/ScrollResponse.ts#L22-L25', '_global.search.Request': '_global/search/SearchRequest.ts#L55-L632', '_global.search.Response': '_global/search/SearchResponse.ts#L34-L37', -'_global.search.ResponseBody': '_global/search/SearchResponse.ts#L39-L85', +'_global.search.ResponseBody': '_global/search/SearchResponse.ts#L39-L93', '_global.search._types.AggregationBreakdown': '_global/search/_types/profile.ts#L27-L40', '_global.search._types.AggregationProfile': '_global/search/_types/profile.ts#L86-L93', '_global.search._types.AggregationProfileDebug': '_global/search/_types/profile.ts#L43-L77', @@ -973,9 +977,9 @@ '_types.query_dsl.BoolQuery': '_types/query_dsl/compound.ts#L29-L56', '_types.query_dsl.BoostingQuery': '_types/query_dsl/compound.ts#L58-L74', '_types.query_dsl.ChildScoreMode': '_types/query_dsl/joining.ts#L25-L39', -'_types.query_dsl.CombinedFieldsOperator': '_types/query_dsl/abstractions.ts#L513-L516', -'_types.query_dsl.CombinedFieldsQuery': '_types/query_dsl/abstractions.ts#L466-L500', -'_types.query_dsl.CombinedFieldsZeroTerms': '_types/query_dsl/abstractions.ts#L518-L527', +'_types.query_dsl.CombinedFieldsOperator': '_types/query_dsl/abstractions.ts#L522-L525', +'_types.query_dsl.CombinedFieldsQuery': '_types/query_dsl/abstractions.ts#L475-L509', +'_types.query_dsl.CombinedFieldsZeroTerms': '_types/query_dsl/abstractions.ts#L527-L536', '_types.query_dsl.CommonTermsQuery': '_types/query_dsl/fulltext.ts#L34-L44', '_types.query_dsl.ConstantScoreQuery': '_types/query_dsl/compound.ts#L76-L86', '_types.query_dsl.DateDecayFunction': '_types/query_dsl/compound.ts#L211-L211', @@ -988,8 +992,8 @@ '_types.query_dsl.DistanceFeatureQuery': '_types/query_dsl/specialized.ts#L76-L85', '_types.query_dsl.DistanceFeatureQueryBase': '_types/query_dsl/specialized.ts#L39-L59', '_types.query_dsl.ExistsQuery': '_types/query_dsl/term.ts#L37-L45', -'_types.query_dsl.FieldAndFormat': '_types/query_dsl/abstractions.ts#L529-L543', -'_types.query_dsl.FieldLookup': '_types/query_dsl/abstractions.ts#L430-L447', +'_types.query_dsl.FieldAndFormat': '_types/query_dsl/abstractions.ts#L538-L552', +'_types.query_dsl.FieldLookup': '_types/query_dsl/abstractions.ts#L439-L456', '_types.query_dsl.FieldValueFactorModifier': '_types/query_dsl/compound.ts#L331-L374', '_types.query_dsl.FieldValueFactorScoreFunction': '_types/query_dsl/compound.ts#L151-L170', '_types.query_dsl.FunctionBoostMode': '_types/query_dsl/compound.ts#L303-L329', @@ -1022,6 +1026,7 @@ '_types.query_dsl.IntervalsRange': '_types/query_dsl/fulltext.ts#L237-L264', '_types.query_dsl.IntervalsRegexp': '_types/query_dsl/fulltext.ts#L266-L281', '_types.query_dsl.IntervalsWildcard': '_types/query_dsl/fulltext.ts#L319-L334', +'_types.query_dsl.KqlQuery': '_types/query_dsl/KqlQuery.ts#L24-L48', '_types.query_dsl.Like': '_types/query_dsl/specialized.ts#L198-L203', '_types.query_dsl.LikeDocument': '_types/query_dsl/specialized.ts#L174-L196', '_types.query_dsl.LongNumberRangeQuery': '_types/query_dsl/term.ts#L170-L170', @@ -1043,8 +1048,8 @@ '_types.query_dsl.PinnedDoc': '_types/query_dsl/specialized.ts#L269-L278', '_types.query_dsl.PinnedQuery': '_types/query_dsl/specialized.ts#L247-L267', '_types.query_dsl.PrefixQuery': '_types/query_dsl/term.ts#L98-L120', -'_types.query_dsl.QueryBase': '_types/query_dsl/abstractions.ts#L453-L464', -'_types.query_dsl.QueryContainer': '_types/query_dsl/abstractions.ts#L97-L428', +'_types.query_dsl.QueryBase': '_types/query_dsl/abstractions.ts#L462-L473', +'_types.query_dsl.QueryContainer': '_types/query_dsl/abstractions.ts#L98-L437', '_types.query_dsl.QueryStringQuery': '_types/query_dsl/fulltext.ts#L650-L773', '_types.query_dsl.RandomScoreFunction': '_types/query_dsl/compound.ts#L145-L149', '_types.query_dsl.RangeQuery': '_types/query_dsl/term.ts#L174-L185', @@ -1091,7 +1096,7 @@ '_types.query_dsl.UntypedRangeQuery': '_types/query_dsl/term.ts#L146-L155', '_types.query_dsl.WeightedTokensQuery': '_types/query_dsl/WeightedTokensQuery.ts#L25-L33', '_types.query_dsl.WildcardQuery': '_types/query_dsl/term.ts#L304-L324', -'_types.query_dsl.WrapperQuery': '_types/query_dsl/abstractions.ts#L502-L511', +'_types.query_dsl.WrapperQuery': '_types/query_dsl/abstractions.ts#L511-L520', '_types.query_dsl.ZeroTermsQuery': '_types/query_dsl/fulltext.ts#L639-L648', 'async_search._types.AsyncSearch': 'async_search/_types/AsyncSearch.ts#L30-L56', 'async_search._types.AsyncSearchDocumentResponseBase': 'async_search/_types/AsyncSearchResponseBase.ts#L54-L58', @@ -1132,18 +1137,18 @@ 'cat._types.CatMasterColumn': 'cat/_types/CatBase.ts#L2151-L2171', 'cat._types.CatNodeColumn': 'cat/_types/CatBase.ts#L567-L1024', 'cat._types.CatNodeattrsColumn': 'cat/_types/CatBase.ts#L2173-L2214', -'cat._types.CatPendingTasksColumn': 'cat/_types/CatBase.ts#L2513-L2535', +'cat._types.CatPendingTasksColumn': 'cat/_types/CatBase.ts#L2531-L2553', 'cat._types.CatPluginsColumn': 'cat/_types/CatBase.ts#L2294-L2320', -'cat._types.CatRecoveryColumn': 'cat/_types/CatBase.ts#L2322-L2468', +'cat._types.CatRecoveryColumn': 'cat/_types/CatBase.ts#L2322-L2486', 'cat._types.CatRequestBase': 'cat/_types/CatBase.ts#L28-L30', 'cat._types.CatSegmentsColumn': 'cat/_types/CatBase.ts#L1026-L1091', -'cat._types.CatShardColumn': 'cat/_types/CatBase.ts#L2854-L3227', +'cat._types.CatShardColumn': 'cat/_types/CatBase.ts#L2872-L3245', 'cat._types.CatSnapshotsColumn': 'cat/_types/CatBase.ts#L1093-L1160', 'cat._types.CatTasksColumn': 'cat/_types/CatBase.ts#L2216-L2292', -'cat._types.CatTemplatesColumn': 'cat/_types/CatBase.ts#L2484-L2511', -'cat._types.CatThreadPoolColumn': 'cat/_types/CatBase.ts#L3230-L3330', -'cat._types.CatTrainedModelsColumn': 'cat/_types/CatBase.ts#L2562-L2636', -'cat._types.CatTransformColumn': 'cat/_types/CatBase.ts#L2641-L2851', +'cat._types.CatTemplatesColumn': 'cat/_types/CatBase.ts#L2502-L2529', +'cat._types.CatThreadPoolColumn': 'cat/_types/CatBase.ts#L3248-L3348', +'cat._types.CatTrainedModelsColumn': 'cat/_types/CatBase.ts#L2580-L2654', +'cat._types.CatTransformColumn': 'cat/_types/CatBase.ts#L2659-L2869', 'cat.aliases.AliasesRecord': 'cat/aliases/types.ts#L22-L53', 'cat.aliases.Request': 'cat/aliases/CatAliasesRequest.ts#L24-L79', 'cat.aliases.Response': 'cat/aliases/CatAliasesResponse.ts#L22-L25', @@ -1193,7 +1198,7 @@ 'cat.plugins.PluginsRecord': 'cat/plugins/types.ts#L22-L52', 'cat.plugins.Request': 'cat/plugins/CatPluginsRequest.ts#L24-L73', 'cat.plugins.Response': 'cat/plugins/CatPluginsResponse.ts#L22-L25', -'cat.recovery.RecoveryRecord': 'cat/recovery/types.ts#L24-L174', +'cat.recovery.RecoveryRecord': 'cat/recovery/types.ts#L24-L192', 'cat.recovery.Request': 'cat/recovery/CatRecoveryRequest.ts#L23-L84', 'cat.recovery.Response': 'cat/recovery/CatRecoveryResponse.ts#L22-L25', 'cat.repositories.RepositoriesRecord': 'cat/repositories/types.ts#L20-L31', @@ -1469,6 +1474,9 @@ 'dangling_indices.list_dangling_indices.DanglingIndex': 'dangling_indices/list_dangling_indices/ListDanglingIndicesResponse.ts#L29-L34', 'dangling_indices.list_dangling_indices.Request': 'dangling_indices/list_dangling_indices/ListDanglingIndicesRequest.ts#L23-L44', 'dangling_indices.list_dangling_indices.Response': 'dangling_indices/list_dangling_indices/ListDanglingIndicesResponse.ts#L23-L27', +'data_recovery.get_recovery_points.RecoveryPoint': 'data_recovery/get_recovery_points/types.ts#L22-L27', +'data_recovery.get_recovery_points.Request': 'data_recovery/get_recovery_points/DataRecoveryGetRecoveryPointsRequest.ts#L25-L63', +'data_recovery.get_recovery_points.Response': 'data_recovery/get_recovery_points/DataRecoveryGetRecoveryPointsResponse.ts#L22-L27', 'encryption.reset.Request': 'encryption/reset/EncryptionResetRequest.ts#L24-L72', 'encryption.reset.Response': 'encryption/reset/EncryptionResetResponse.ts#L22-L25', 'enrich._types.Policy': 'enrich/_types/Policy.ts#L34-L41', @@ -1514,15 +1522,15 @@ 'esql._types.EsqlQuerySettings': 'esql/_types/types.ts#L179-L216', 'esql._types.IdPath': 'esql/_types/types.ts#L91-L99', 'esql._types.TableValuesContainer': 'esql/_types/TableValuesContainer.ts#L22-L28', -'esql.delete_data_source.Request': 'esql/delete_data_source/DeleteDataSourceRequest.ts#L24-L62', +'esql.delete_data_source.Request': 'esql/delete_data_source/DeleteDataSourceRequest.ts#L24-L63', 'esql.delete_data_source.Response': 'esql/delete_data_source/DeleteDataSourceResponse.ts#L22-L25', -'esql.delete_dataset.Request': 'esql/delete_dataset/DeleteDatasetRequest.ts#L24-L61', +'esql.delete_dataset.Request': 'esql/delete_dataset/DeleteDatasetRequest.ts#L24-L62', 'esql.delete_dataset.Response': 'esql/delete_dataset/DeleteDatasetResponse.ts#L22-L25', 'esql.delete_view.Request': 'esql/delete_view/DeleteViewRequest.ts#L23-L47', 'esql.delete_view.Response': 'esql/delete_view/DeleteViewResponse.ts#L22-L25', -'esql.get_data_source.Request': 'esql/get_data_source/GetDataSourceRequest.ts#L24-L61', +'esql.get_data_source.Request': 'esql/get_data_source/GetDataSourceRequest.ts#L24-L62', 'esql.get_data_source.Response': 'esql/get_data_source/GetDataSourceResponse.ts#L22-L30', -'esql.get_dataset.Request': 'esql/get_dataset/GetDatasetRequest.ts#L24-L61', +'esql.get_dataset.Request': 'esql/get_dataset/GetDatasetRequest.ts#L24-L62', 'esql.get_dataset.Response': 'esql/get_dataset/GetDatasetResponse.ts#L22-L27', 'esql.get_query.Request': 'esql/get_query/GetQueryRequest.ts#L23-L47', 'esql.get_query.Response': 'esql/get_query/GetQueryResponse.ts#L23-L33', @@ -1531,14 +1539,17 @@ 'esql.list_queries.Body': 'esql/list_queries/ListQueriesResponse.ts#L24-L30', 'esql.list_queries.Request': 'esql/list_queries/ListQueriesRequest.ts#L23-L43', 'esql.list_queries.Response': 'esql/list_queries/ListQueriesResponse.ts#L32-L36', -'esql.put_data_source.Request': 'esql/put_data_source/PutDataSourceRequest.ts#L26-L79', +'esql.put_data_source.Request': 'esql/put_data_source/PutDataSourceRequest.ts#L26-L80', 'esql.put_data_source.Response': 'esql/put_data_source/PutDataSourceResponse.ts#L22-L25', -'esql.put_dataset.Request': 'esql/put_dataset/PutDatasetRequest.ts#L27-L86', +'esql.put_dataset.Request': 'esql/put_dataset/PutDatasetRequest.ts#L27-L87', 'esql.put_dataset.Response': 'esql/put_dataset/PutDatasetResponse.ts#L22-L25', 'esql.put_view.Request': 'esql/put_view/PutViewRequest.ts#L23-L51', 'esql.put_view.Response': 'esql/put_view/PutViewResponse.ts#L22-L25', 'esql.query.Request': 'esql/query/QueryRequest.ts#L28-L155', 'esql.query.Response': 'esql/query/QueryResponse.ts#L22-L25', +'esql.test_data_source_connection.DataSourceTestStatus': 'esql/test_data_source_connection/TestDataSourceConnectionResponse.ts#L20-L35', +'esql.test_data_source_connection.Request': 'esql/test_data_source_connection/TestDataSourceConnectionRequest.ts#L25-L62', +'esql.test_data_source_connection.Response': 'esql/test_data_source_connection/TestDataSourceConnectionResponse.ts#L37-L53', 'features._types.Feature': 'features/_types/Feature.ts#L20-L23', 'features.get_features.Request': 'features/get_features/GetFeaturesRequest.ts#L24-L56', 'features.get_features.Response': 'features/get_features/GetFeaturesResponse.ts#L22-L26', @@ -1854,7 +1865,7 @@ 'indices.recovery.RecoveryType': 'indices/recovery/types.ts#L140-L151', 'indices.recovery.Request': 'indices/recovery/IndicesRecoveryRequest.ts#L23-L110', 'indices.recovery.Response': 'indices/recovery/IndicesRecoveryResponse.ts#L24-L27', -'indices.recovery.ShardRecovery': 'indices/recovery/types.ts#L171-L221', +'indices.recovery.ShardRecovery': 'indices/recovery/types.ts#L171-L237', 'indices.recovery.TranslogStatus': 'indices/recovery/types.ts#L102-L109', 'indices.recovery.VerifyIndex': 'indices/recovery/types.ts#L111-L116', 'indices.refresh.Request': 'indices/refresh/IndicesRefreshRequest.ts#L23-L94', @@ -1959,6 +1970,14 @@ 'inference._types.AzureOpenAITaskSettings': 'inference/_types/CommonTypes.ts#L1061-L1078', 'inference._types.AzureOpenAITaskType': 'inference/_types/CommonTypes.ts#L1080-L1084', 'inference._types.BaseReasoningDetail': 'inference/_types/CommonTypes.ts#L405-L422', +'inference._types.ChatCompletionChoice': 'inference/_types/Results.ts#L200-L218', +'inference._types.ChatCompletionCompletionTokensDetails': 'inference/_types/Results.ts#L234-L242', +'inference._types.ChatCompletionInferenceResult': 'inference/_types/Results.ts#L272-L297', +'inference._types.ChatCompletionMessage': 'inference/_types/Results.ts#L168-L198', +'inference._types.ChatCompletionPromptTokensDetails': 'inference/_types/Results.ts#L220-L232', +'inference._types.ChatCompletionToolCall': 'inference/_types/Results.ts#L146-L166', +'inference._types.ChatCompletionToolCallFunction': 'inference/_types/Results.ts#L132-L144', +'inference._types.ChatCompletionUsage': 'inference/_types/Results.ts#L244-L270', 'inference._types.CohereEmbeddingType': 'inference/_types/CommonTypes.ts#L1141-L1147', 'inference._types.CohereInputType': 'inference/_types/CommonTypes.ts#L1149-L1154', 'inference._types.CohereServiceSettings': 'inference/_types/CommonTypes.ts#L1090-L1129', @@ -1967,8 +1986,8 @@ 'inference._types.CohereTaskSettings': 'inference/_types/CommonTypes.ts#L1168-L1200', 'inference._types.CohereTaskType': 'inference/_types/CommonTypes.ts#L1131-L1135', 'inference._types.CohereTruncateType': 'inference/_types/CommonTypes.ts#L1162-L1166', -'inference._types.CompletionInferenceResult': 'inference/_types/Results.ts#L98-L103', -'inference._types.CompletionResult': 'inference/_types/Results.ts#L91-L96', +'inference._types.CompletionInferenceResult': 'inference/_types/Results.ts#L99-L104', +'inference._types.CompletionResult': 'inference/_types/Results.ts#L92-L97', 'inference._types.CompletionTool': 'inference/_types/CommonTypes.ts#L513-L525', 'inference._types.CompletionToolChoice': 'inference/_types/CommonTypes.ts#L476-L488', 'inference._types.CompletionToolChoiceFunction': 'inference/_types/CommonTypes.ts#L465-L474', @@ -1989,9 +2008,9 @@ 'inference._types.CustomTaskType': 'inference/_types/CommonTypes.ts#L1457-L1462', 'inference._types.DeepSeekServiceSettings': 'inference/_types/CommonTypes.ts#L1530-L1550', 'inference._types.DeepSeekServiceType': 'inference/_types/CommonTypes.ts#L1552-L1554', -'inference._types.DeleteInferenceEndpointResult': 'inference/_types/Results.ts#L124-L129', -'inference._types.DenseEmbeddingByteResult': 'inference/_types/Results.ts#L57-L62', -'inference._types.DenseEmbeddingResult': 'inference/_types/Results.ts#L64-L69', +'inference._types.DeleteInferenceEndpointResult': 'inference/_types/Results.ts#L125-L130', +'inference._types.DenseEmbeddingByteResult': 'inference/_types/Results.ts#L58-L63', +'inference._types.DenseEmbeddingResult': 'inference/_types/Results.ts#L65-L70', 'inference._types.ElasticsearchServiceSettings': 'inference/_types/CommonTypes.ts#L1556-L1612', 'inference._types.ElasticsearchServiceType': 'inference/_types/CommonTypes.ts#L1628-L1630', 'inference._types.ElasticsearchTaskSettings': 'inference/_types/CommonTypes.ts#L1614-L1620', @@ -2003,7 +2022,7 @@ 'inference._types.EmbeddingContentObject': 'inference/_types/CommonTypes.ts#L631-L639', 'inference._types.EmbeddingContentObjectItem': 'inference/_types/CommonTypes.ts#L649-L667', 'inference._types.EmbeddingContentType': 'inference/_types/CommonTypes.ts#L669-L679', -'inference._types.EmbeddingInferenceResult': 'inference/_types/Results.ts#L81-L89', +'inference._types.EmbeddingInferenceResult': 'inference/_types/Results.ts#L82-L90', 'inference._types.EmbeddingInput': 'inference/_types/CommonTypes.ts#L612-L617', 'inference._types.EncryptedReasoningDetail': 'inference/_types/CommonTypes.ts#L424-L434', 'inference._types.FileContent': 'inference/_types/CommonTypes.ts#L205-L214', @@ -2058,7 +2077,7 @@ 'inference._types.InferenceEndpointInfoOpenShiftAi': 'inference/_types/Services.ts#L342-L351', 'inference._types.InferenceEndpointInfoVoyageAI': 'inference/_types/Services.ts#L353-L362', 'inference._types.InferenceEndpointInfoWatsonx': 'inference/_types/Services.ts#L364-L373', -'inference._types.InferenceResult': 'inference/_types/Results.ts#L131-L145', +'inference._types.InferenceResult': 'inference/_types/Results.ts#L299-L313', 'inference._types.JinaAIElementType': 'inference/_types/CommonTypes.ts#L2028-L2032', 'inference._types.JinaAIServiceSettings': 'inference/_types/CommonTypes.ts#L1923-L1971', 'inference._types.JinaAIServiceType': 'inference/_types/CommonTypes.ts#L2011-L2013', @@ -2091,7 +2110,7 @@ 'inference._types.OpenShiftAiSimilarityType': 'inference/_types/CommonTypes.ts#L2330-L2334', 'inference._types.OpenShiftAiTaskSettings': 'inference/_types/CommonTypes.ts#L2336-L2345', 'inference._types.OpenShiftAiTaskType': 'inference/_types/CommonTypes.ts#L2319-L2324', -'inference._types.RankedDocument': 'inference/_types/Results.ts#L105-L115', +'inference._types.RankedDocument': 'inference/_types/Results.ts#L106-L116', 'inference._types.RateLimitSetting': 'inference/_types/Services.ts#L440-L471', 'inference._types.Reasoning': 'inference/_types/CommonTypes.ts#L216-L246', 'inference._types.ReasoningDetail': 'inference/_types/CommonTypes.ts#L395-L403', @@ -2101,9 +2120,9 @@ 'inference._types.RegionPolicyDoc': 'inference/_types/RegionPolicy.ts#L54-L75', 'inference._types.RequestChatCompletion': 'inference/_types/CommonTypes.ts#L26-L133', 'inference._types.RequestEmbedding': 'inference/_types/CommonTypes.ts#L527-L610', -'inference._types.RerankedInferenceResult': 'inference/_types/Results.ts#L117-L122', -'inference._types.SparseEmbeddingInferenceResult': 'inference/_types/Results.ts#L44-L49', -'inference._types.SparseEmbeddingResult': 'inference/_types/Results.ts#L36-L42', +'inference._types.RerankedInferenceResult': 'inference/_types/Results.ts#L118-L123', +'inference._types.SparseEmbeddingInferenceResult': 'inference/_types/Results.ts#L45-L50', +'inference._types.SparseEmbeddingResult': 'inference/_types/Results.ts#L37-L43', 'inference._types.SummaryReasoningDetail': 'inference/_types/CommonTypes.ts#L436-L446', 'inference._types.TaskType': 'inference/_types/TaskType.ts#L20-L30', 'inference._types.TaskTypeAi21': 'inference/_types/TaskType.ts#L38-L41', @@ -2132,7 +2151,7 @@ 'inference._types.TaskTypeOpenShiftAi': 'inference/_types/TaskType.ts#L162-L167', 'inference._types.TaskTypeVoyageAI': 'inference/_types/TaskType.ts#L169-L172', 'inference._types.TaskTypeWatsonx': 'inference/_types/TaskType.ts#L180-L184', -'inference._types.TextEmbeddingInferenceResult': 'inference/_types/Results.ts#L71-L79', +'inference._types.TextEmbeddingInferenceResult': 'inference/_types/Results.ts#L72-L80', 'inference._types.TextReasoningDetail': 'inference/_types/CommonTypes.ts#L448-L463', 'inference._types.ThinkingConfig': 'inference/_types/CommonTypes.ts#L1818-L1823', 'inference._types.ToolCall': 'inference/_types/CommonTypes.ts#L277-L293', @@ -2160,6 +2179,8 @@ 'inference.get_region_policy.Response': 'inference/get_region_policy/GetRegionPolicyResponse.ts#L22-L25', 'inference.inference.Request': 'inference/inference/InferenceRequest.ts#L26-L106', 'inference.inference.Response': 'inference/inference/InferenceResponse.ts#L22-L25', +'inference.non_streaming_chat_completion.Request': 'inference/non_streaming_chat_completion/UnifiedRequest.ts#L24-L78', +'inference.non_streaming_chat_completion.Response': 'inference/non_streaming_chat_completion/UnifiedResponse.ts#L22-L25', 'inference.put.Request': 'inference/put/PutRequest.ts#L26-L96', 'inference.put.Response': 'inference/put/PutResponse.ts#L22-L25', 'inference.put_ai21.Request': 'inference/put_ai21/PutAi21Request.ts#L29-L75', @@ -2390,8 +2411,8 @@ 'ml._types.CategorizationAnalyzerDefinition': 'ml/_types/Analysis.ts#L119-L133', 'ml._types.CategorizationStatus': 'ml/_types/Model.ts#L84-L87', 'ml._types.Category': 'ml/_types/Category.ts#L23-L49', -'ml._types.ChunkingConfig': 'ml/_types/Datafeed.ts#L271-L284', -'ml._types.ChunkingMode': 'ml/_types/Datafeed.ts#L265-L269', +'ml._types.ChunkingConfig': 'ml/_types/Datafeed.ts#L275-L288', +'ml._types.ChunkingMode': 'ml/_types/Datafeed.ts#L269-L273', 'ml._types.ClassificationInferenceOptions': 'ml/_types/inference.ts#L118-L133', 'ml._types.CommonTokenizationConfig': 'ml/_types/inference.ts#L160-L186', 'ml._types.ConditionOperator': 'ml/_types/Rule.ts#L74-L79', @@ -2399,11 +2420,11 @@ 'ml._types.DataDescription': 'ml/_types/Job.ts#L376-L392', 'ml._types.Datafeed': 'ml/_types/Datafeed.ts#L37-L72', 'ml._types.DatafeedAuthorization': 'ml/_types/Authorization.ts#L31-L44', -'ml._types.DatafeedConfig': 'ml/_types/Datafeed.ts#L74-L140', -'ml._types.DatafeedRunningState': 'ml/_types/Datafeed.ts#L230-L244', -'ml._types.DatafeedState': 'ml/_types/Datafeed.ts#L156-L161', -'ml._types.DatafeedStats': 'ml/_types/Datafeed.ts#L163-L192', -'ml._types.DatafeedTimingStats': 'ml/_types/Datafeed.ts#L194-L222', +'ml._types.DatafeedConfig': 'ml/_types/Datafeed.ts#L74-L144', +'ml._types.DatafeedRunningState': 'ml/_types/Datafeed.ts#L234-L248', +'ml._types.DatafeedState': 'ml/_types/Datafeed.ts#L160-L165', +'ml._types.DatafeedStats': 'ml/_types/Datafeed.ts#L167-L196', +'ml._types.DatafeedTimingStats': 'ml/_types/Datafeed.ts#L198-L226', 'ml._types.DataframeAnalysis': 'ml/_types/DataframeAnalytics.ts#L134-L213', 'ml._types.DataframeAnalysisAnalyzedFields': 'ml/_types/DataframeAnalytics.ts#L238-L244', 'ml._types.DataframeAnalysisClassification': 'ml/_types/DataframeAnalytics.ts#L227-L236', @@ -2441,7 +2462,7 @@ 'ml._types.DataframeEvaluationRegressionMetricsHuber': 'ml/_types/DataframeEvaluation.ts#L117-L120', 'ml._types.DataframeEvaluationRegressionMetricsMsle': 'ml/_types/DataframeEvaluation.ts#L112-L115', 'ml._types.DataframeState': 'ml/_types/Dataframe.ts#L20-L26', -'ml._types.DelayedDataCheckConfig': 'ml/_types/Datafeed.ts#L142-L153', +'ml._types.DelayedDataCheckConfig': 'ml/_types/Datafeed.ts#L146-L157', 'ml._types.DeploymentAllocationState': 'ml/_types/TrainedModel.ts#L334-L347', 'ml._types.DeploymentAssignmentState': 'ml/_types/TrainedModel.ts#L349-L366', 'ml._types.DetectionRule': 'ml/_types/Rule.ts#L25-L39', @@ -2451,7 +2472,7 @@ 'ml._types.DiscoveryNodeCompact': 'ml/_types/DiscoveryNode.ts#L39-L48', 'ml._types.DiscoveryNodeContent': 'ml/_types/DiscoveryNode.ts#L27-L37', 'ml._types.ExcludeFrequent': 'ml/_types/Detector.ts#L91-L96', -'ml._types.ExponentialAverageCalculationContext': 'ml/_types/Datafeed.ts#L224-L228', +'ml._types.ExponentialAverageCalculationContext': 'ml/_types/Datafeed.ts#L228-L232', 'ml._types.FillMaskInferenceOptions': 'ml/_types/inference.ts#L286-L303', 'ml._types.FillMaskInferenceUpdateOptions': 'ml/_types/inference.ts#L434-L441', 'ml._types.Filter': 'ml/_types/Filter.ts#L22-L29', @@ -2501,7 +2522,7 @@ 'ml._types.RoutingState': 'ml/_types/TrainedModel.ts#L411-L432', 'ml._types.RuleAction': 'ml/_types/Rule.ts#L41-L50', 'ml._types.RuleCondition': 'ml/_types/Rule.ts#L52-L65', -'ml._types.RunningStateSearchInterval': 'ml/_types/Datafeed.ts#L246-L263', +'ml._types.RunningStateSearchInterval': 'ml/_types/Datafeed.ts#L250-L267', 'ml._types.SnapshotUpgradeState': 'ml/_types/Model.ts#L95-L100', 'ml._types.TextClassificationInferenceOptions': 'ml/_types/inference.ts#L202-L214', 'ml._types.TextClassificationInferenceUpdateOptions': 'ml/_types/inference.ts#L386-L395', @@ -2665,8 +2686,8 @@ 'ml.put_calendar_job.Response': 'ml/put_calendar_job/MlPutCalendarJobResponse.ts#L22-L31', 'ml.put_data_frame_analytics.Request': 'ml/put_data_frame_analytics/MlPutDataFrameAnalyticsRequest.ts#L36-L164', 'ml.put_data_frame_analytics.Response': 'ml/put_data_frame_analytics/MlPutDataFrameAnalyticsResponse.ts#L31-L47', -'ml.put_datafeed.Request': 'ml/put_datafeed/MlPutDatafeedRequest.ts#L38-L202', -'ml.put_datafeed.Response': 'ml/put_datafeed/MlPutDatafeedResponse.ts#L31-L57', +'ml.put_datafeed.Request': 'ml/put_datafeed/MlPutDatafeedRequest.ts#L38-L210', +'ml.put_datafeed.Response': 'ml/put_datafeed/MlPutDatafeedResponse.ts#L31-L58', 'ml.put_filter.Request': 'ml/put_filter/MlPutFilterRequest.ts#L23-L61', 'ml.put_filter.Response': 'ml/put_filter/MlPutFilterResponse.ts#L22-L28', 'ml.put_job.Request': 'ml/put_job/MlPutJobRequest.ts#L30-L159', @@ -2711,8 +2732,8 @@ 'ml.stop_trained_model_deployment.Response': 'ml/stop_trained_model_deployment/MlStopTrainedModelDeploymentResponse.ts#L20-L22', 'ml.update_data_frame_analytics.Request': 'ml/update_data_frame_analytics/MlUpdateDataFrameAnalyticsRequest.ts#L24-L83', 'ml.update_data_frame_analytics.Response': 'ml/update_data_frame_analytics/MlUpdateDataFrameAnalyticsResponse.ts#L30-L45', -'ml.update_datafeed.Request': 'ml/update_datafeed/MlUpdateDatafeedRequest.ts#L31-L189', -'ml.update_datafeed.Response': 'ml/update_datafeed/MlUpdateDatafeedResponse.ts#L31-L60', +'ml.update_datafeed.Request': 'ml/update_datafeed/MlUpdateDatafeedRequest.ts#L31-L197', +'ml.update_datafeed.Response': 'ml/update_datafeed/MlUpdateDatafeedResponse.ts#L31-L61', 'ml.update_filter.Request': 'ml/update_filter/MlUpdateFilterRequest.ts#L23-L63', 'ml.update_filter.Response': 'ml/update_filter/MlUpdateFilterResponse.ts#L22-L28', 'ml.update_job.Request': 'ml/update_job/MlUpdateJobRequest.ts#L33-L150', @@ -2980,29 +3001,29 @@ 'security._types.Access': 'security/_types/Access.ts#L22-L31', 'security._types.ApiKey': 'security/_types/ApiKey.ts#L27-L120', 'security._types.ApiKeyType': 'security/_types/ApiKey.ts#L122-L125', -'security._types.ApplicationGlobalUserPrivileges': 'security/_types/Privileges.ts#L427-L429', +'security._types.ApplicationGlobalUserPrivileges': 'security/_types/Privileges.ts#L431-L433', 'security._types.ApplicationPrivileges': 'security/_types/Privileges.ts#L28-L41', 'security._types.BulkError': 'security/_types/Bulk.ts#L24-L33', 'security._types.ClusterNode': 'security/_types/ClusterNode.ts#L22-L24', -'security._types.ClusterPrivilege': 'security/_types/Privileges.ts#L43-L220', +'security._types.ClusterPrivilege': 'security/_types/Privileges.ts#L43-L224', 'security._types.CreatedStatus': 'security/_types/CreatedStatus.ts#L20-L22', 'security._types.CredentialManagedBy': 'security/_types/CredentialManagedBy.ts#L20-L23', -'security._types.DataSourcePrivilege': 'security/_types/Privileges.ts#L446-L468', -'security._types.DataSourcePrivileges': 'security/_types/Privileges.ts#L435-L444', +'security._types.DataSourcePrivilege': 'security/_types/Privileges.ts#L450-L472', +'security._types.DataSourcePrivileges': 'security/_types/Privileges.ts#L439-L448', 'security._types.FieldSecurity': 'security/_types/FieldSecurity.ts#L22-L25', -'security._types.GlobalPrivilege': 'security/_types/Privileges.ts#L418-L425', +'security._types.GlobalPrivilege': 'security/_types/Privileges.ts#L422-L429', 'security._types.GrantType': 'security/_types/GrantType.ts#L20-L30', -'security._types.IndexPrivilege': 'security/_types/Privileges.ts#L370-L416', -'security._types.IndicesPrivileges': 'security/_types/Privileges.ts#L264-L264', -'security._types.IndicesPrivilegesQuery': 'security/_types/Privileges.ts#L325-L333', -'security._types.ManageUserPrivileges': 'security/_types/Privileges.ts#L431-L433', +'security._types.IndexPrivilege': 'security/_types/Privileges.ts#L374-L420', +'security._types.IndicesPrivileges': 'security/_types/Privileges.ts#L268-L268', +'security._types.IndicesPrivilegesQuery': 'security/_types/Privileges.ts#L329-L337', +'security._types.ManageUserPrivileges': 'security/_types/Privileges.ts#L435-L437', 'security._types.NodeSecurityStats': 'security/_types/NodeSecurityStats.ts#L22-L27', 'security._types.RealmInfo': 'security/_types/RealmInfo.ts#L22-L25', -'security._types.RemoteClusterPrivilege': 'security/_types/Privileges.ts#L222-L234', -'security._types.RemoteClusterPrivileges': 'security/_types/Privileges.ts#L278-L290', -'security._types.RemoteIndicesPrivileges': 'security/_types/Privileges.ts#L266-L276', -'security._types.RemoteUserIndicesPrivileges': 'security/_types/Privileges.ts#L319-L323', -'security._types.ReplicationAccess': 'security/_types/Privileges.ts#L470-L480', +'security._types.RemoteClusterPrivilege': 'security/_types/Privileges.ts#L226-L238', +'security._types.RemoteClusterPrivileges': 'security/_types/Privileges.ts#L282-L294', +'security._types.RemoteIndicesPrivileges': 'security/_types/Privileges.ts#L270-L280', +'security._types.RemoteUserIndicesPrivileges': 'security/_types/Privileges.ts#L323-L327', +'security._types.ReplicationAccess': 'security/_types/Privileges.ts#L474-L484', 'security._types.Restriction': 'security/_types/RoleDescriptor.ts#L90-L96', 'security._types.RestrictionWorkflow': 'security/_types/RoleDescriptor.ts#L98-L101', 'security._types.RoleDescriptor': 'security/_types/RoleDescriptor.ts#L33-L83', @@ -3010,15 +3031,15 @@ 'security._types.RoleMapping': 'security/_types/RoleMapping.ts#L25-L33', 'security._types.RoleMappingRule': 'security/_types/RoleMappingRule.ts#L23-L31', 'security._types.RoleTemplate': 'security/_types/RoleTemplate.ts#L28-L31', -'security._types.RoleTemplateInlineQuery': 'security/_types/Privileges.ts#L367-L368', -'security._types.RoleTemplateQuery': 'security/_types/Privileges.ts#L335-L345', -'security._types.RoleTemplateScript': 'security/_types/Privileges.ts#L347-L365', +'security._types.RoleTemplateInlineQuery': 'security/_types/Privileges.ts#L371-L372', +'security._types.RoleTemplateQuery': 'security/_types/Privileges.ts#L339-L349', +'security._types.RoleTemplateScript': 'security/_types/Privileges.ts#L351-L369', 'security._types.RolesStats': 'security/_types/NodeSecurityStats.ts#L29-L34', -'security._types.SearchAccess': 'security/_types/Privileges.ts#L482-L502', +'security._types.SearchAccess': 'security/_types/Privileges.ts#L486-L506', 'security._types.SecuritySettings': 'security/_types/SecuritySettings.ts#L22-L24', 'security._types.TemplateFormat': 'security/_types/RoleTemplate.ts#L22-L25', 'security._types.User': 'security/_types/User.ts#L23-L31', -'security._types.UserIndicesPrivileges': 'security/_types/Privileges.ts#L316-L317', +'security._types.UserIndicesPrivileges': 'security/_types/Privileges.ts#L320-L321', 'security._types.UserProfile': 'security/_types/UserProfile.ts#L41-L47', 'security._types.UserProfileHitMetadata': 'security/_types/UserProfile.ts#L27-L30', 'security._types.UserProfileUser': 'security/_types/UserProfile.ts#L32-L39', @@ -3053,7 +3074,7 @@ 'security.create_api_key.Response': 'security/create_api_key/SecurityCreateApiKeyResponse.ts#L23-L50', 'security.create_cross_cluster_api_key.Request': 'security/create_cross_cluster_api_key/CreateCrossClusterApiKeyRequest.ts#L25-L88', 'security.create_cross_cluster_api_key.Response': 'security/create_cross_cluster_api_key/CreateCrossClusterApiKeyResponse.ts#L23-L48', -'security.create_service_token.Request': 'security/create_service_token/CreateServiceTokenRequest.ts#L23-L79', +'security.create_service_token.Request': 'security/create_service_token/CreateServiceTokenRequest.ts#L23-L80', 'security.create_service_token.Response': 'security/create_service_token/CreateServiceTokenResponse.ts#L22-L30', 'security.create_service_token.Token': 'security/create_service_token/types.ts#L22-L25', 'security.delegate_pki.Authentication': 'security/delegate_pki/SecurityDelegatePkiResponse.ts#L43-L55', @@ -3067,10 +3088,12 @@ 'security.delete_role.Response': 'security/delete_role/SecurityDeleteRoleResponse.ts#L20-L28', 'security.delete_role_mapping.Request': 'security/delete_role_mapping/SecurityDeleteRoleMappingRequest.ts#L23-L57', 'security.delete_role_mapping.Response': 'security/delete_role_mapping/SecurityDeleteRoleMappingResponse.ts#L20-L28', -'security.delete_service_token.Request': 'security/delete_service_token/DeleteServiceTokenRequest.ts#L23-L65', +'security.delete_service_token.Request': 'security/delete_service_token/DeleteServiceTokenRequest.ts#L23-L66', 'security.delete_service_token.Response': 'security/delete_service_token/DeleteServiceTokenResponse.ts#L20-L28', 'security.delete_user.Request': 'security/delete_user/SecurityDeleteUserRequest.ts#L23-L52', 'security.delete_user.Response': 'security/delete_user/SecurityDeleteUserResponse.ts#L20-L28', +'security.delete_user_managed_service_account.Request': 'security/delete_user_managed_service_account/DeleteUserManagedServiceAccountRequest.ts#L23-L74', +'security.delete_user_managed_service_account.Response': 'security/delete_user_managed_service_account/DeleteUserManagedServiceAccountResponse.ts#L20-L28', 'security.disable_user.Request': 'security/disable_user/SecurityDisableUserRequest.ts#L23-L54', 'security.disable_user.Response': 'security/disable_user/SecurityDisableUserResponse.ts#L20-L22', 'security.disable_user_profile.Request': 'security/disable_user_profile/Request.ts#L24-L64', @@ -3096,9 +3119,12 @@ 'security.get_role.Role': 'security/get_role/types.ts#L50-L72', 'security.get_role_mapping.Request': 'security/get_role_mapping/SecurityGetRoleMappingRequest.ts#L23-L54', 'security.get_role_mapping.Response': 'security/get_role_mapping/SecurityGetRoleMappingResponse.ts#L23-L29', -'security.get_service_accounts.Request': 'security/get_service_accounts/GetServiceAccountsRequest.ts#L23-L65', +'security.get_service_accounts.BuiltInServiceAccount': 'security/get_service_accounts/types.ts#L38-L49', +'security.get_service_accounts.Request': 'security/get_service_accounts/GetServiceAccountsRequest.ts#L24-L77', 'security.get_service_accounts.Response': 'security/get_service_accounts/GetServiceAccountsResponse.ts#L23-L29', -'security.get_service_accounts.RoleDescriptorWrapper': 'security/get_service_accounts/types.ts#L22-L24', +'security.get_service_accounts.ServiceAccountInfo': 'security/get_service_accounts/types.ts#L29-L36', +'security.get_service_accounts.ServiceAccountType': 'security/get_service_accounts/types.ts#L22-L27', +'security.get_service_accounts.UserManagedServiceAccount': 'security/get_service_accounts/types.ts#L51-L66', 'security.get_service_credentials.NodesCredentials': 'security/get_service_credentials/types.ts#L23-L28', 'security.get_service_credentials.NodesCredentialsFileToken': 'security/get_service_credentials/types.ts#L30-L32', 'security.get_service_credentials.Request': 'security/get_service_credentials/GetServiceCredentialsRequest.ts#L23-L57', @@ -3107,12 +3133,12 @@ 'security.get_settings.Response': 'security/get_settings/SecurityGetSettingsResponse.ts#L21-L36', 'security.get_stats.Request': 'security/get_stats/SecurityStatsRequest.ts#L23-L43', 'security.get_stats.Response': 'security/get_stats/SecurityStatsResponse.ts#L24-L31', -'security.get_token.AccessTokenGrantType': 'security/get_token/types.ts#L23-L48', -'security.get_token.AuthenticatedUser': 'security/get_token/types.ts#L60-L65', -'security.get_token.AuthenticationProvider': 'security/get_token/types.ts#L55-L58', -'security.get_token.Request': 'security/get_token/GetUserAccessTokenRequest.ts#L25-L92', +'security.get_token.AccessTokenGrantType': 'security/get_token/types.ts#L23-L58', +'security.get_token.AuthenticatedUser': 'security/get_token/types.ts#L70-L75', +'security.get_token.AuthenticationProvider': 'security/get_token/types.ts#L65-L68', +'security.get_token.Request': 'security/get_token/GetUserAccessTokenRequest.ts#L25-L99', 'security.get_token.Response': 'security/get_token/GetUserAccessTokenResponse.ts#L23-L33', -'security.get_token.UserRealm': 'security/get_token/types.ts#L50-L53', +'security.get_token.UserRealm': 'security/get_token/types.ts#L60-L63', 'security.get_user.Request': 'security/get_user/SecurityGetUserRequest.ts#L23-L57', 'security.get_user.Response': 'security/get_user/SecurityGetUserResponse.ts#L23-L30', 'security.get_user_privileges.Request': 'security/get_user_privileges/SecurityGetUserPrivilegesRequest.ts#L23-L43', @@ -3151,6 +3177,8 @@ 'security.put_role_mapping.Response': 'security/put_role_mapping/SecurityPutRoleMappingResponse.ts#L22-L24', 'security.put_user.Request': 'security/put_user/SecurityPutUserRequest.ts#L29-L109', 'security.put_user.Response': 'security/put_user/SecurityPutUserResponse.ts#L20-L28', +'security.put_user_managed_service_account.Request': 'security/put_user_managed_service_account/PutUserManagedServiceAccountRequest.ts#L23-L82', +'security.put_user_managed_service_account.Response': 'security/put_user_managed_service_account/PutUserManagedServiceAccountResponse.ts#L20-L28', 'security.query_api_keys.ApiKeyAggregate': 'security/query_api_keys/types.ts#L122-L139', 'security.query_api_keys.ApiKeyAggregationContainer': 'security/query_api_keys/types.ts#L63-L120', 'security.query_api_keys.ApiKeyFiltersAggregation': 'security/query_api_keys/types.ts#L207-L227', @@ -3642,10 +3670,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/c698d0135ddaae5a65a38580c4a1b6865f6a7a0a/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/e744367bd16925ef0b72942405797f12aaa1ac2a/specification/" + (paths[hash] || ""); - 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/ElasticsearchEsqlAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ElasticsearchEsqlAsyncClient.java index 3db7549c01..943b26d5df 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ElasticsearchEsqlAsyncClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/ElasticsearchEsqlAsyncClient.java @@ -562,6 +562,52 @@ public final CompletableFuture query( return query(fn.apply(new QueryRequest.Builder()).build()); } + // ----- Endpoint: esql.test_data_source_connection + + /** + * Test an ES|QL data source connection. + *

+ * Tests whether the supplied data source configuration can establish a live + * connection. The data source does not need to exist in cluster state: this + * endpoint is intended for validating a new configuration before saving it. The + * request body accepts the same type and settings + * fields as the create or update data source API. + * + * @see Documentation + * on elastic.co + */ + + public CompletableFuture testDataSourceConnection( + TestDataSourceConnectionRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) TestDataSourceConnectionRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Test an ES|QL data source connection. + *

+ * Tests whether the supplied data source configuration can establish a live + * connection. The data source does not need to exist in cluster state: this + * endpoint is intended for validating a new configuration before saving it. The + * request body accepts the same type and settings + * fields as the create or update data source API. + * + * @param fn + * a function that initializes a builder to create the + * {@link TestDataSourceConnectionRequest} + * @see Documentation + * on elastic.co + */ + + public final CompletableFuture testDataSourceConnection( + Function> fn) { + return testDataSourceConnection(fn.apply(new TestDataSourceConnectionRequest.Builder()).build()); + } + /** * Executes an ES|QL request and adapts its result to a target type. * 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 c71c03695b..bb086d03e9 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 @@ -571,6 +571,53 @@ public final BinaryResponse query(Function + * Tests whether the supplied data source configuration can establish a live + * connection. The data source does not need to exist in cluster state: this + * endpoint is intended for validating a new configuration before saving it. The + * request body accepts the same type and settings + * fields as the create or update data source API. + * + * @see Documentation + * on elastic.co + */ + + public TestDataSourceConnectionResponse testDataSourceConnection(TestDataSourceConnectionRequest request) + throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) TestDataSourceConnectionRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Test an ES|QL data source connection. + *

+ * Tests whether the supplied data source configuration can establish a live + * connection. The data source does not need to exist in cluster state: this + * endpoint is intended for validating a new configuration before saving it. The + * request body accepts the same type and settings + * fields as the create or update data source API. + * + * @param fn + * a function that initializes a builder to create the + * {@link TestDataSourceConnectionRequest} + * @see Documentation + * on elastic.co + */ + + public final TestDataSourceConnectionResponse testDataSourceConnection( + Function> fn) + throws IOException, ElasticsearchException { + return testDataSourceConnection(fn.apply(new TestDataSourceConnectionRequest.Builder()).build()); + } + /** * Executes an ES|QL request and adapts its result to a target type. * diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/TestDataSourceConnectionRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/TestDataSourceConnectionRequest.java new file mode 100644 index 0000000000..20a5f05445 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/TestDataSourceConnectionRequest.java @@ -0,0 +1,273 @@ +/* + * 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.esql; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.RequestBase; +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.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.Collections; +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: esql.test_data_source_connection.Request + +/** + * Test an ES|QL data source connection. + *

+ * Tests whether the supplied data source configuration can establish a live + * connection. The data source does not need to exist in cluster state: this + * endpoint is intended for validating a new configuration before saving it. The + * request body accepts the same type and settings + * fields as the create or update data source API. + * + * @see API + * specification + */ +@JsonpDeserializable +public class TestDataSourceConnectionRequest extends RequestBase implements JsonpSerializable { + private final Map settings; + + private final String type; + + // --------------------------------------------------------------------------------------------- + + private TestDataSourceConnectionRequest(Builder builder) { + + this.settings = ApiTypeHelper.unmodifiable(builder.settings); + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + + } + + public static TestDataSourceConnectionRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Type-specific connection and authentication settings to test. Uses the same + * structure as the settings field in the create or update data + * source API. + *

+ * API name: {@code settings} + */ + public final Map settings() { + return this.settings; + } + + /** + * Required - The data source type to test. Must be a known, registered type + * such as s3, gcs, or azure. Unknown + * types return a 400 error. + *

+ * API name: {@code type} + */ + public final String 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) { + + if (ApiTypeHelper.isDefined(this.settings)) { + generator.writeKey("settings"); + generator.writeStartObject(); + for (Map.Entry item0 : this.settings.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("type"); + generator.write(this.type); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link TestDataSourceConnectionRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private Map settings; + + private String type; + + public Builder() { + } + private Builder(TestDataSourceConnectionRequest instance) { + this.settings = instance.settings; + this.type = instance.type; + + } + /** + * Type-specific connection and authentication settings to test. Uses the same + * structure as the settings field in the create or update data + * source API. + *

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

+ * Adds all entries of map to settings. + */ + public final Builder settings(Map map) { + this.settings = _mapPutAll(this.settings, map); + return this; + } + + /** + * Type-specific connection and authentication settings to test. Uses the same + * structure as the settings field in the create or update data + * source API. + *

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

+ * Adds an entry to settings. + */ + public final Builder settings(String key, JsonData value) { + this.settings = _mapPut(this.settings, key, value); + return this; + } + + /** + * Required - The data source type to test. Must be a known, registered type + * such as s3, gcs, or azure. Unknown + * types return a 400 error. + *

+ * API name: {@code type} + */ + public final Builder type(String value) { + this.type = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link TestDataSourceConnectionRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public TestDataSourceConnectionRequest build() { + _checkSingleUse(); + + return new TestDataSourceConnectionRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link TestDataSourceConnectionRequest} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, TestDataSourceConnectionRequest::setupTestDataSourceConnectionRequestDeserializer); + + protected static void setupTestDataSourceConnectionRequestDeserializer( + ObjectDeserializer op) { + + op.add(Builder::settings, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "settings"); + op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code esql.test_data_source_connection}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/esql.test_data_source_connection", + + // Request method + request -> { + return "POST"; + + }, + + // Request path + request -> { + return "/_query/data_source/_test"; + + }, + + // Path parameters + request -> { + return Collections.emptyMap(); + }, + + // Request parameters + request -> { + return Collections.emptyMap(); + + }, SimpleEndpoint.emptyMap(), true, TestDataSourceConnectionResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/TestDataSourceConnectionResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/TestDataSourceConnectionResponse.java new file mode 100644 index 0000000000..43cc8dfd74 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/TestDataSourceConnectionResponse.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.esql; + +import co.elastic.clients.elasticsearch.esql.test_data_source_connection.DataSourceTestStatus; +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: esql.test_data_source_connection.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class TestDataSourceConnectionResponse implements JsonpSerializable { + private final DataSourceTestStatus status; + + @Nullable + private final String error; + + @Nullable + private final String message; + + // --------------------------------------------------------------------------------------------- + + private TestDataSourceConnectionResponse(Builder builder) { + + this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); + this.error = builder.error; + this.message = builder.message; + + } + + public static TestDataSourceConnectionResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The outcome of the connection test. + *

+ * API name: {@code status} + */ + public final DataSourceTestStatus status() { + return this.status; + } + + /** + * A human-readable description of why the connection failed. Present only when + * status is failure. + *

+ * API name: {@code error} + */ + @Nullable + public final String error() { + return this.error; + } + + /** + * Optional user-visible guidance explaining why the connection could not be + * tested. Present only when status is untestable and + * additional context is available. + *

+ * API name: {@code message} + */ + @Nullable + public final String message() { + return this.message; + } + + /** + * 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("status"); + this.status.serialize(generator, mapper); + if (this.error != null) { + generator.writeKey("error"); + generator.write(this.error); + + } + if (this.message != null) { + generator.writeKey("message"); + generator.write(this.message); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link TestDataSourceConnectionResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private DataSourceTestStatus status; + + @Nullable + private String error; + + @Nullable + private String message; + + /** + * Required - The outcome of the connection test. + *

+ * API name: {@code status} + */ + public final Builder status(DataSourceTestStatus value) { + this.status = value; + return this; + } + + /** + * A human-readable description of why the connection failed. Present only when + * status is failure. + *

+ * API name: {@code error} + */ + public final Builder error(@Nullable String value) { + this.error = value; + return this; + } + + /** + * Optional user-visible guidance explaining why the connection could not be + * tested. Present only when status is untestable and + * additional context is available. + *

+ * API name: {@code message} + */ + public final Builder message(@Nullable String value) { + this.message = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link TestDataSourceConnectionResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public TestDataSourceConnectionResponse build() { + _checkSingleUse(); + + return new TestDataSourceConnectionResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link TestDataSourceConnectionResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, TestDataSourceConnectionResponse::setupTestDataSourceConnectionResponseDeserializer); + + protected static void setupTestDataSourceConnectionResponseDeserializer( + ObjectDeserializer op) { + + op.add(Builder::status, DataSourceTestStatus._DESERIALIZER, "status"); + op.add(Builder::error, JsonpDeserializer.stringDeserializer(), "error"); + op.add(Builder::message, JsonpDeserializer.stringDeserializer(), "message"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/test_data_source_connection/DataSourceTestStatus.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/test_data_source_connection/DataSourceTestStatus.java new file mode 100644 index 0000000000..3d619721ea --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/test_data_source_connection/DataSourceTestStatus.java @@ -0,0 +1,82 @@ +/* + * 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.esql.test_data_source_connection; + +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 DataSourceTestStatus implements JsonEnum { + /** + * The probe ran and the backend is reachable from every eligible data node. + */ + Success("success"), + + /** + * The probe ran but the backend was unreachable or rejected the connection. The + * error field carries a human-readable reason. + */ + Failure("failure"), + + /** + * The type is valid and registered, but the probe cannot give a meaningful + * result — for example, no connectivity target, anonymous credentials, or + * bucket-scoped credentials. The optional message field may carry + * user-visible guidance. + */ + Untestable("untestable"), + + ; + + private final String jsonValue; + + DataSourceTestStatus(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + DataSourceTestStatus.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/recovery/ShardRecovery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/recovery/ShardRecovery.java index c091485e99..c67a034d7c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/recovery/ShardRecovery.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/recovery/ShardRecovery.java @@ -35,6 +35,7 @@ import java.lang.Boolean; import java.lang.Integer; import java.lang.Long; +import java.lang.String; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -80,6 +81,12 @@ public class ShardRecovery implements JsonpSerializable { @Nullable private final RecoveryPriority priority; + @Nullable + private final String gate; + + @Nullable + private final Long blockedForMillis; + @Nullable private final RecoveryStartStatus start; @@ -118,6 +125,8 @@ private ShardRecovery(Builder builder) { this.stage = ApiTypeHelper.requireNonNull(builder.stage, this, "stage"); this.localRetries = builder.localRetries; this.priority = builder.priority; + this.gate = builder.gate; + this.blockedForMillis = builder.blockedForMillis; this.start = builder.start; this.startTime = builder.startTime; this.startTimeInMillis = ApiTypeHelper.requireNonNull(builder.startTimeInMillis, this, "startTimeInMillis", 0); @@ -194,6 +203,31 @@ public final RecoveryPriority priority() { return this.priority; } + /** + * The name of the recovery gate that blocked recovery on the target node. + *

+ * Only present for queued recoveries in the CREATED stage that are + * blocked by a recovery gate. + *

+ * API name: {@code gate} + */ + @Nullable + public final String gate() { + return this.gate; + } + + /** + * The elapsed time in milliseconds recovery is blocked for. + *

+ * Only present with gate. + *

+ * API name: {@code blocked_for_millis} + */ + @Nullable + public final Long blockedForMillis() { + return this.blockedForMillis; + } + /** * API name: {@code start} */ @@ -329,6 +363,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("priority"); this.priority.serialize(generator, mapper); } + if (this.gate != null) { + generator.writeKey("gate"); + generator.write(this.gate); + + } + if (this.blockedForMillis != null) { + generator.writeKey("blocked_for_millis"); + generator.write(this.blockedForMillis); + + } if (this.start != null) { generator.writeKey("start"); this.start.serialize(generator, mapper); @@ -399,6 +443,12 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private RecoveryPriority priority; + @Nullable + private String gate; + + @Nullable + private Long blockedForMillis; + @Nullable private RecoveryStartStatus start; @@ -436,6 +486,8 @@ private Builder(ShardRecovery instance) { this.stage = instance.stage; this.localRetries = instance.localRetries; this.priority = instance.priority; + this.gate = instance.gate; + this.blockedForMillis = instance.blockedForMillis; this.start = instance.start; this.startTime = instance.startTime; this.startTimeInMillis = instance.startTimeInMillis; @@ -526,6 +578,31 @@ public final Builder priority(@Nullable RecoveryPriority value) { return this; } + /** + * The name of the recovery gate that blocked recovery on the target node. + *

+ * Only present for queued recoveries in the CREATED stage that are + * blocked by a recovery gate. + *

+ * API name: {@code gate} + */ + public final Builder gate(@Nullable String value) { + this.gate = value; + return this; + } + + /** + * The elapsed time in milliseconds recovery is blocked for. + *

+ * Only present with gate. + *

+ * API name: {@code blocked_for_millis} + */ + public final Builder blockedForMillis(@Nullable Long value) { + this.blockedForMillis = value; + return this; + } + /** * API name: {@code start} */ @@ -709,6 +786,8 @@ protected static void setupShardRecoveryDeserializer(ObjectDeserializerAPI + * specification + */ +@JsonpDeserializable +public class ChatCompletionChoice implements JsonpSerializable { + private final ChatCompletionMessage message; + + @Nullable + private final String finishReason; + + private final int index; + + // --------------------------------------------------------------------------------------------- + + private ChatCompletionChoice(Builder builder) { + + this.message = ApiTypeHelper.requireNonNull(builder.message, this, "message"); + this.finishReason = builder.finishReason; + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index", 0); + + } + + public static ChatCompletionChoice of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The message generated by the model for this choice. + *

+ * API name: {@code message} + */ + public final ChatCompletionMessage message() { + return this.message; + } + + /** + * The reason the model stopped generating tokens. Common values are + * stop (natural stopping point) and tool_calls (the + * model called a tool). Omitted when the reason is not available. + *

+ * API name: {@code finish_reason} + */ + @Nullable + public final String finishReason() { + return this.finishReason; + } + + /** + * Required - The index of this choice in the list of choices. + *

+ * API name: {@code index} + */ + public final int index() { + return this.index; + } + + /** + * 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("message"); + this.message.serialize(generator, mapper); + + if (this.finishReason != null) { + generator.writeKey("finish_reason"); + generator.write(this.finishReason); + + } + generator.writeKey("index"); + generator.write(this.index); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChatCompletionChoice}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private ChatCompletionMessage message; + + @Nullable + private String finishReason; + + private Integer index; + + public Builder() { + } + private Builder(ChatCompletionChoice instance) { + this.message = instance.message; + this.finishReason = instance.finishReason; + this.index = instance.index; + + } + /** + * Required - The message generated by the model for this choice. + *

+ * API name: {@code message} + */ + public final Builder message(ChatCompletionMessage value) { + this.message = value; + return this; + } + + /** + * Required - The message generated by the model for this choice. + *

+ * API name: {@code message} + */ + public final Builder message(Function> fn) { + return this.message(fn.apply(new ChatCompletionMessage.Builder()).build()); + } + + /** + * The reason the model stopped generating tokens. Common values are + * stop (natural stopping point) and tool_calls (the + * model called a tool). Omitted when the reason is not available. + *

+ * API name: {@code finish_reason} + */ + public final Builder finishReason(@Nullable String value) { + this.finishReason = value; + return this; + } + + /** + * Required - The index of this choice in the list of choices. + *

+ * API name: {@code index} + */ + public final Builder index(int value) { + this.index = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ChatCompletionChoice}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChatCompletionChoice build() { + _checkSingleUse(); + + return new ChatCompletionChoice(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChatCompletionChoice} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ChatCompletionChoice::setupChatCompletionChoiceDeserializer); + + protected static void setupChatCompletionChoiceDeserializer(ObjectDeserializer op) { + + op.add(Builder::message, ChatCompletionMessage._DESERIALIZER, "message"); + op.add(Builder::finishReason, JsonpDeserializer.stringDeserializer(), "finish_reason"); + op.add(Builder::index, JsonpDeserializer.integerDeserializer(), "index"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionCompletionTokensDetails.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionCompletionTokensDetails.java new file mode 100644 index 0000000000..ba64fd558f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionCompletionTokensDetails.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.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.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: inference._types.ChatCompletionCompletionTokensDetails + +/** + * Breakdown of tokens used in the request. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ChatCompletionCompletionTokensDetails implements JsonpSerializable { + @Nullable + private final Integer reasoningTokens; + + // --------------------------------------------------------------------------------------------- + + private ChatCompletionCompletionTokensDetails(Builder builder) { + + this.reasoningTokens = builder.reasoningTokens; + + } + + public static ChatCompletionCompletionTokensDetails of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The number of tokens used for reasoning by the model. + *

+ * API name: {@code reasoning_tokens} + */ + @Nullable + public final Integer reasoningTokens() { + return this.reasoningTokens; + } + + /** + * 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.reasoningTokens != null) { + generator.writeKey("reasoning_tokens"); + generator.write(this.reasoningTokens); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChatCompletionCompletionTokensDetails}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private Integer reasoningTokens; + + public Builder() { + } + private Builder(ChatCompletionCompletionTokensDetails instance) { + this.reasoningTokens = instance.reasoningTokens; + + } + /** + * The number of tokens used for reasoning by the model. + *

+ * API name: {@code reasoning_tokens} + */ + public final Builder reasoningTokens(@Nullable Integer value) { + this.reasoningTokens = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ChatCompletionCompletionTokensDetails}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChatCompletionCompletionTokensDetails build() { + _checkSingleUse(); + + return new ChatCompletionCompletionTokensDetails(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChatCompletionCompletionTokensDetails} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + ChatCompletionCompletionTokensDetails::setupChatCompletionCompletionTokensDetailsDeserializer); + + protected static void setupChatCompletionCompletionTokensDetailsDeserializer( + ObjectDeserializer op) { + + op.add(Builder::reasoningTokens, JsonpDeserializer.integerDeserializer(), "reasoning_tokens"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionInferenceResult.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionInferenceResult.java new file mode 100644 index 0000000000..5e7dd1ac33 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionInferenceResult.java @@ -0,0 +1,296 @@ +/* + * 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.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.ChatCompletionInferenceResult + +/** + * The response format for the non-streaming unified chat completion request. + * + * @see API + * specification + */ + +public abstract class ChatCompletionInferenceResult implements JsonpSerializable { + private final String id; + + private final List choices; + + private final String model; + + private final String object; + + @Nullable + private final ChatCompletionUsage usage; + + // --------------------------------------------------------------------------------------------- + + protected ChatCompletionInferenceResult(AbstractBuilder builder) { + + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.choices = ApiTypeHelper.unmodifiable(builder.choices); + this.model = ApiTypeHelper.requireNonNull(builder.model, this, "model"); + this.object = ApiTypeHelper.requireNonNull(builder.object, this, "object"); + this.usage = builder.usage; + + } + + /** + * Required - The unique identifier for the completion. + *

+ * API name: {@code id} + */ + public final String id() { + return this.id; + } + + /** + * The list of completion choices the model generated for the input message. + *

+ * API name: {@code choices} + */ + public final List choices() { + return this.choices; + } + + /** + * Required - The model used to generate the completion. + *

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

+ * API name: {@code object} + */ + public final String object() { + return this.object; + } + + /** + * The token usage statistics for the completion request. Omitted when usage + * information is not available. + *

+ * API name: {@code usage} + */ + @Nullable + public final ChatCompletionUsage usage() { + return this.usage; + } + + /** + * 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.choices)) { + generator.writeKey("choices"); + generator.writeStartArray(); + for (ChatCompletionChoice item0 : this.choices) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("model"); + generator.write(this.model); + + generator.writeKey("object"); + generator.write(this.object); + + if (this.usage != null) { + generator.writeKey("usage"); + this.usage.serialize(generator, mapper); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + private String id; + + @Nullable + private List choices; + + private String model; + + private String object; + + @Nullable + private ChatCompletionUsage usage; + + /** + * Required - The unique identifier for the completion. + *

+ * API name: {@code id} + */ + public final BuilderT id(String value) { + this.id = value; + return self(); + } + + /** + * The list of completion choices the model generated for the input message. + *

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

+ * Adds all elements of list to choices. + */ + public final BuilderT choices(List list) { + this.choices = _listAddAll(this.choices, list); + return self(); + } + + /** + * The list of completion choices the model generated for the input message. + *

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

+ * Adds one or more values to choices. + */ + public final BuilderT choices(ChatCompletionChoice value, ChatCompletionChoice... values) { + this.choices = _listAdd(this.choices, value, values); + return self(); + } + + /** + * The list of completion choices the model generated for the input message. + *

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

+ * Adds a value to choices using a builder lambda. + */ + public final BuilderT choices(Function> fn) { + return choices(fn.apply(new ChatCompletionChoice.Builder()).build()); + } + + /** + * Required - The model used to generate the completion. + *

+ * API name: {@code model} + */ + public final BuilderT model(String value) { + this.model = value; + return self(); + } + + /** + * Required - The object type. + *

+ * API name: {@code object} + */ + public final BuilderT object(String value) { + this.object = value; + return self(); + } + + /** + * The token usage statistics for the completion request. Omitted when usage + * information is not available. + *

+ * API name: {@code usage} + */ + public final BuilderT usage(@Nullable ChatCompletionUsage value) { + this.usage = value; + return self(); + } + + /** + * The token usage statistics for the completion request. Omitted when usage + * information is not available. + *

+ * API name: {@code usage} + */ + public final BuilderT usage(Function> fn) { + return this.usage(fn.apply(new ChatCompletionUsage.Builder()).build()); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupChatCompletionInferenceResultDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(AbstractBuilder::choices, JsonpDeserializer.arrayDeserializer(ChatCompletionChoice._DESERIALIZER), + "choices"); + op.add(AbstractBuilder::model, JsonpDeserializer.stringDeserializer(), "model"); + op.add(AbstractBuilder::object, JsonpDeserializer.stringDeserializer(), "object"); + op.add(AbstractBuilder::usage, ChatCompletionUsage._DESERIALIZER, "usage"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionMessage.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionMessage.java new file mode 100644 index 0000000000..3e702d4953 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionMessage.java @@ -0,0 +1,415 @@ +/* + * 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.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.ChatCompletionMessage + +/** + * The message returned by the model. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ChatCompletionMessage implements JsonpSerializable { + @Nullable + private final String content; + + @Nullable + private final String refusal; + + @Nullable + private final String role; + + @Nullable + private final String reasoning; + + private final List toolCalls; + + private final List reasoningDetails; + + // --------------------------------------------------------------------------------------------- + + private ChatCompletionMessage(Builder builder) { + + this.content = builder.content; + this.refusal = builder.refusal; + this.role = builder.role; + this.reasoning = builder.reasoning; + this.toolCalls = ApiTypeHelper.unmodifiable(builder.toolCalls); + this.reasoningDetails = ApiTypeHelper.unmodifiable(builder.reasoningDetails); + + } + + public static ChatCompletionMessage of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The content of the message. + *

+ * API name: {@code content} + */ + @Nullable + public final String content() { + return this.content; + } + + /** + * The refusal message generated by the model. + *

+ * API name: {@code refusal} + */ + @Nullable + public final String refusal() { + return this.refusal; + } + + /** + * The role of the message author. + *

+ * API name: {@code role} + */ + @Nullable + public final String role() { + return this.role; + } + + /** + * The reasoning generated by the model as plaintext. Currently supported only + * for the elastic provider. + *

+ * API name: {@code reasoning} + */ + @Nullable + public final String reasoning() { + return this.reasoning; + } + + /** + * The tool calls generated by the model. + *

+ * API name: {@code tool_calls} + */ + public final List toolCalls() { + return this.toolCalls; + } + + /** + * The reasoning details generated by the model as structured data. Currently + * supported only for the elastic provider. + *

+ * API name: {@code reasoning_details} + */ + public final List reasoningDetails() { + return this.reasoningDetails; + } + + /** + * 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.content != null) { + generator.writeKey("content"); + generator.write(this.content); + + } + if (this.refusal != null) { + generator.writeKey("refusal"); + generator.write(this.refusal); + + } + if (this.role != null) { + generator.writeKey("role"); + generator.write(this.role); + + } + if (this.reasoning != null) { + generator.writeKey("reasoning"); + generator.write(this.reasoning); + + } + if (ApiTypeHelper.isDefined(this.toolCalls)) { + generator.writeKey("tool_calls"); + generator.writeStartArray(); + for (ChatCompletionToolCall item0 : this.toolCalls) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (ApiTypeHelper.isDefined(this.reasoningDetails)) { + generator.writeKey("reasoning_details"); + generator.writeStartArray(); + for (ReasoningDetail item0 : this.reasoningDetails) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChatCompletionMessage}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private String content; + + @Nullable + private String refusal; + + @Nullable + private String role; + + @Nullable + private String reasoning; + + @Nullable + private List toolCalls; + + @Nullable + private List reasoningDetails; + + public Builder() { + } + private Builder(ChatCompletionMessage instance) { + this.content = instance.content; + this.refusal = instance.refusal; + this.role = instance.role; + this.reasoning = instance.reasoning; + this.toolCalls = instance.toolCalls; + this.reasoningDetails = instance.reasoningDetails; + + } + /** + * The content of the message. + *

+ * API name: {@code content} + */ + public final Builder content(@Nullable String value) { + this.content = value; + return this; + } + + /** + * The refusal message generated by the model. + *

+ * API name: {@code refusal} + */ + public final Builder refusal(@Nullable String value) { + this.refusal = value; + return this; + } + + /** + * The role of the message author. + *

+ * API name: {@code role} + */ + public final Builder role(@Nullable String value) { + this.role = value; + return this; + } + + /** + * The reasoning generated by the model as plaintext. Currently supported only + * for the elastic provider. + *

+ * API name: {@code reasoning} + */ + public final Builder reasoning(@Nullable String value) { + this.reasoning = value; + return this; + } + + /** + * The tool calls generated by the model. + *

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

+ * Adds all elements of list to toolCalls. + */ + public final Builder toolCalls(List list) { + this.toolCalls = _listAddAll(this.toolCalls, list); + return this; + } + + /** + * The tool calls generated by the model. + *

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

+ * Adds one or more values to toolCalls. + */ + public final Builder toolCalls(ChatCompletionToolCall value, ChatCompletionToolCall... values) { + this.toolCalls = _listAdd(this.toolCalls, value, values); + return this; + } + + /** + * The tool calls generated by the model. + *

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

+ * Adds a value to toolCalls using a builder lambda. + */ + public final Builder toolCalls( + Function> fn) { + return toolCalls(fn.apply(new ChatCompletionToolCall.Builder()).build()); + } + + /** + * The reasoning details generated by the model as structured data. Currently + * supported only for the elastic provider. + *

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

+ * Adds all elements of list to reasoningDetails. + */ + public final Builder reasoningDetails(List list) { + this.reasoningDetails = _listAddAll(this.reasoningDetails, list); + return this; + } + + /** + * The reasoning details generated by the model as structured data. Currently + * supported only for the elastic provider. + *

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

+ * Adds one or more values to reasoningDetails. + */ + public final Builder reasoningDetails(ReasoningDetail value, ReasoningDetail... values) { + this.reasoningDetails = _listAdd(this.reasoningDetails, value, values); + return this; + } + + /** + * The reasoning details generated by the model as structured data. Currently + * supported only for the elastic provider. + *

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

+ * Adds a value to reasoningDetails using a builder lambda. + */ + public final Builder reasoningDetails(Function> fn) { + return reasoningDetails(fn.apply(new ReasoningDetail.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ChatCompletionMessage}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChatCompletionMessage build() { + _checkSingleUse(); + + return new ChatCompletionMessage(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChatCompletionMessage} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ChatCompletionMessage::setupChatCompletionMessageDeserializer); + + protected static void setupChatCompletionMessageDeserializer(ObjectDeserializer op) { + + op.add(Builder::content, JsonpDeserializer.stringDeserializer(), "content"); + op.add(Builder::refusal, JsonpDeserializer.stringDeserializer(), "refusal"); + op.add(Builder::role, JsonpDeserializer.stringDeserializer(), "role"); + op.add(Builder::reasoning, JsonpDeserializer.stringDeserializer(), "reasoning"); + op.add(Builder::toolCalls, JsonpDeserializer.arrayDeserializer(ChatCompletionToolCall._DESERIALIZER), + "tool_calls"); + op.add(Builder::reasoningDetails, JsonpDeserializer.arrayDeserializer(ReasoningDetail._DESERIALIZER), + "reasoning_details"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionPromptTokensDetails.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionPromptTokensDetails.java new file mode 100644 index 0000000000..b59b11b6e8 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionPromptTokensDetails.java @@ -0,0 +1,214 @@ +/* + * 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.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: inference._types.ChatCompletionPromptTokensDetails + +/** + * Breakdown of tokens used in the prompt. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ChatCompletionPromptTokensDetails implements JsonpSerializable { + @Nullable + private final Integer cachedTokens; + + @Nullable + private final Integer cacheWriteTokens; + + // --------------------------------------------------------------------------------------------- + + private ChatCompletionPromptTokensDetails(Builder builder) { + + this.cachedTokens = builder.cachedTokens; + this.cacheWriteTokens = builder.cacheWriteTokens; + + } + + public static ChatCompletionPromptTokensDetails of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The number of tokens that were cached from a previous request. + *

+ * API name: {@code cached_tokens} + */ + @Nullable + public final Integer cachedTokens() { + return this.cachedTokens; + } + + /** + * The number of tokens written to the cache. + *

+ * API name: {@code cache_write_tokens} + */ + @Nullable + public final Integer cacheWriteTokens() { + return this.cacheWriteTokens; + } + + /** + * 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.cachedTokens != null) { + generator.writeKey("cached_tokens"); + generator.write(this.cachedTokens); + + } + if (this.cacheWriteTokens != null) { + generator.writeKey("cache_write_tokens"); + generator.write(this.cacheWriteTokens); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChatCompletionPromptTokensDetails}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private Integer cachedTokens; + + @Nullable + private Integer cacheWriteTokens; + + public Builder() { + } + private Builder(ChatCompletionPromptTokensDetails instance) { + this.cachedTokens = instance.cachedTokens; + this.cacheWriteTokens = instance.cacheWriteTokens; + + } + /** + * The number of tokens that were cached from a previous request. + *

+ * API name: {@code cached_tokens} + */ + public final Builder cachedTokens(@Nullable Integer value) { + this.cachedTokens = value; + return this; + } + + /** + * The number of tokens written to the cache. + *

+ * API name: {@code cache_write_tokens} + */ + public final Builder cacheWriteTokens(@Nullable Integer value) { + this.cacheWriteTokens = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ChatCompletionPromptTokensDetails}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChatCompletionPromptTokensDetails build() { + _checkSingleUse(); + + return new ChatCompletionPromptTokensDetails(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChatCompletionPromptTokensDetails} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ChatCompletionPromptTokensDetails::setupChatCompletionPromptTokensDetailsDeserializer); + + protected static void setupChatCompletionPromptTokensDetailsDeserializer( + ObjectDeserializer op) { + + op.add(Builder::cachedTokens, JsonpDeserializer.integerDeserializer(), "cached_tokens"); + op.add(Builder::cacheWriteTokens, JsonpDeserializer.integerDeserializer(), "cache_write_tokens"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionToolCall.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionToolCall.java new file mode 100644 index 0000000000..e9097d349f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionToolCall.java @@ -0,0 +1,284 @@ +/* + * 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.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.ChatCompletionToolCall + +/** + * A tool call generated by the model. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ChatCompletionToolCall implements JsonpSerializable { + private final int index; + + @Nullable + private final String id; + + @Nullable + private final ChatCompletionToolCallFunction function; + + private final String type; + + // --------------------------------------------------------------------------------------------- + + private ChatCompletionToolCall(Builder builder) { + + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index", 0); + this.id = builder.id; + this.function = builder.function; + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + + } + + public static ChatCompletionToolCall of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The index of the tool call in the list of tool calls generated by + * the model. + *

+ * API name: {@code index} + */ + public final int index() { + return this.index; + } + + /** + * The identifier of the tool call. + *

+ * API name: {@code id} + */ + @Nullable + public final String id() { + return this.id; + } + + /** + * The function that the model called. + *

+ * API name: {@code function} + */ + @Nullable + public final ChatCompletionToolCallFunction function() { + return this.function; + } + + /** + * Required - The type of the tool call. + *

+ * API name: {@code type} + */ + public final String 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("index"); + generator.write(this.index); + + if (this.id != null) { + generator.writeKey("id"); + generator.write(this.id); + + } + if (this.function != null) { + generator.writeKey("function"); + this.function.serialize(generator, mapper); + + } + generator.writeKey("type"); + generator.write(this.type); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChatCompletionToolCall}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Integer index; + + @Nullable + private String id; + + @Nullable + private ChatCompletionToolCallFunction function; + + private String type; + + public Builder() { + } + private Builder(ChatCompletionToolCall instance) { + this.index = instance.index; + this.id = instance.id; + this.function = instance.function; + this.type = instance.type; + + } + /** + * Required - The index of the tool call in the list of tool calls generated by + * the model. + *

+ * API name: {@code index} + */ + public final Builder index(int value) { + this.index = value; + return this; + } + + /** + * The identifier of the tool call. + *

+ * API name: {@code id} + */ + public final Builder id(@Nullable String value) { + this.id = value; + return this; + } + + /** + * The function that the model called. + *

+ * API name: {@code function} + */ + public final Builder function(@Nullable ChatCompletionToolCallFunction value) { + this.function = value; + return this; + } + + /** + * The function that the model called. + *

+ * API name: {@code function} + */ + public final Builder function( + Function> fn) { + return this.function(fn.apply(new ChatCompletionToolCallFunction.Builder()).build()); + } + + /** + * Required - The type of the tool call. + *

+ * API name: {@code type} + */ + public final Builder type(String value) { + this.type = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ChatCompletionToolCall}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChatCompletionToolCall build() { + _checkSingleUse(); + + return new ChatCompletionToolCall(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChatCompletionToolCall} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ChatCompletionToolCall::setupChatCompletionToolCallDeserializer); + + protected static void setupChatCompletionToolCallDeserializer( + ObjectDeserializer op) { + + op.add(Builder::index, JsonpDeserializer.integerDeserializer(), "index"); + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(Builder::function, ChatCompletionToolCallFunction._DESERIALIZER, "function"); + op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionToolCallFunction.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionToolCallFunction.java new file mode 100644 index 0000000000..d61bab2d96 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionToolCallFunction.java @@ -0,0 +1,214 @@ +/* + * 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.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.ChatCompletionToolCallFunction + +/** + * The function called by the tool. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ChatCompletionToolCallFunction implements JsonpSerializable { + @Nullable + private final String arguments; + + @Nullable + private final String name; + + // --------------------------------------------------------------------------------------------- + + private ChatCompletionToolCallFunction(Builder builder) { + + this.arguments = builder.arguments; + this.name = builder.name; + + } + + public static ChatCompletionToolCallFunction of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The arguments to call the function with, as a JSON string. + *

+ * API name: {@code arguments} + */ + @Nullable + public final String arguments() { + return this.arguments; + } + + /** + * The name of the function. + *

+ * 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) { + + if (this.arguments != null) { + generator.writeKey("arguments"); + generator.write(this.arguments); + + } + if (this.name != null) { + generator.writeKey("name"); + generator.write(this.name); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChatCompletionToolCallFunction}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private String arguments; + + @Nullable + private String name; + + public Builder() { + } + private Builder(ChatCompletionToolCallFunction instance) { + this.arguments = instance.arguments; + this.name = instance.name; + + } + /** + * The arguments to call the function with, as a JSON string. + *

+ * API name: {@code arguments} + */ + public final Builder arguments(@Nullable String value) { + this.arguments = value; + return this; + } + + /** + * The name of the function. + *

+ * 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 ChatCompletionToolCallFunction}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChatCompletionToolCallFunction build() { + _checkSingleUse(); + + return new ChatCompletionToolCallFunction(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChatCompletionToolCallFunction} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ChatCompletionToolCallFunction::setupChatCompletionToolCallFunctionDeserializer); + + protected static void setupChatCompletionToolCallFunctionDeserializer( + ObjectDeserializer op) { + + op.add(Builder::arguments, JsonpDeserializer.stringDeserializer(), "arguments"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionUnifiedRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionUnifiedRequest.java index c1b596ea76..f73a6ed650 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionUnifiedRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionUnifiedRequest.java @@ -61,20 +61,19 @@ // typedef: inference.chat_completion_unified.Request /** - * Perform chat completion inference on the service. + * Perform streaming chat completion inference on the service. *

* The chat completion inference API enables real-time responses for chat * completion tasks by delivering answers incrementally, reducing response times * during computation. It only works with the chat_completion task * type. *

- * NOTE: The chat_completion task type is only available within the - * _stream API and only supports streaming. The Chat completion inference API - * and the Stream inference API differ in their response structure and - * capabilities. The Chat completion inference API provides more comprehensive - * customization options through more fields and function calling support. To - * determine whether a given inference service supports this task type, please - * see the page for that service. + * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API and the Stream inference API + * differ in their response structure and capabilities. The Chat completion + * inference API provides more comprehensive customization options through more + * fields and function calling support. To determine whether a given inference + * service supports this task type, please see the page for that service. * * @see API diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionUsage.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionUsage.java new file mode 100644 index 0000000000..a2ce4183b2 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ChatCompletionUsage.java @@ -0,0 +1,327 @@ +/* + * 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.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: inference._types.ChatCompletionUsage + +/** + * Token usage statistics for the request. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ChatCompletionUsage implements JsonpSerializable { + private final int completionTokens; + + private final int promptTokens; + + private final int totalTokens; + + @Nullable + private final ChatCompletionPromptTokensDetails promptTokensDetails; + + @Nullable + private final ChatCompletionCompletionTokensDetails completionTokensDetails; + + // --------------------------------------------------------------------------------------------- + + private ChatCompletionUsage(Builder builder) { + + this.completionTokens = ApiTypeHelper.requireNonNull(builder.completionTokens, this, "completionTokens", 0); + this.promptTokens = ApiTypeHelper.requireNonNull(builder.promptTokens, this, "promptTokens", 0); + this.totalTokens = ApiTypeHelper.requireNonNull(builder.totalTokens, this, "totalTokens", 0); + this.promptTokensDetails = builder.promptTokensDetails; + this.completionTokensDetails = builder.completionTokensDetails; + + } + + public static ChatCompletionUsage of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The number of tokens in the generated completion. + *

+ * API name: {@code completion_tokens} + */ + public final int completionTokens() { + return this.completionTokens; + } + + /** + * Required - The number of tokens in the prompt. + *

+ * API name: {@code prompt_tokens} + */ + public final int promptTokens() { + return this.promptTokens; + } + + /** + * Required - The total number of tokens used (prompt + completion). + *

+ * API name: {@code total_tokens} + */ + public final int totalTokens() { + return this.totalTokens; + } + + /** + * Breakdown of the tokens used in the prompt. Omitted when no details are + * available. + *

+ * API name: {@code prompt_tokens_details} + */ + @Nullable + public final ChatCompletionPromptTokensDetails promptTokensDetails() { + return this.promptTokensDetails; + } + + /** + * Breakdown of the tokens used in the completion. Omitted when no details are + * available. + *

+ * API name: {@code completion_tokens_details} + */ + @Nullable + public final ChatCompletionCompletionTokensDetails completionTokensDetails() { + return this.completionTokensDetails; + } + + /** + * 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("completion_tokens"); + generator.write(this.completionTokens); + + generator.writeKey("prompt_tokens"); + generator.write(this.promptTokens); + + generator.writeKey("total_tokens"); + generator.write(this.totalTokens); + + if (this.promptTokensDetails != null) { + generator.writeKey("prompt_tokens_details"); + this.promptTokensDetails.serialize(generator, mapper); + + } + if (this.completionTokensDetails != null) { + generator.writeKey("completion_tokens_details"); + this.completionTokensDetails.serialize(generator, mapper); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ChatCompletionUsage}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Integer completionTokens; + + private Integer promptTokens; + + private Integer totalTokens; + + @Nullable + private ChatCompletionPromptTokensDetails promptTokensDetails; + + @Nullable + private ChatCompletionCompletionTokensDetails completionTokensDetails; + + public Builder() { + } + private Builder(ChatCompletionUsage instance) { + this.completionTokens = instance.completionTokens; + this.promptTokens = instance.promptTokens; + this.totalTokens = instance.totalTokens; + this.promptTokensDetails = instance.promptTokensDetails; + this.completionTokensDetails = instance.completionTokensDetails; + + } + /** + * Required - The number of tokens in the generated completion. + *

+ * API name: {@code completion_tokens} + */ + public final Builder completionTokens(int value) { + this.completionTokens = value; + return this; + } + + /** + * Required - The number of tokens in the prompt. + *

+ * API name: {@code prompt_tokens} + */ + public final Builder promptTokens(int value) { + this.promptTokens = value; + return this; + } + + /** + * Required - The total number of tokens used (prompt + completion). + *

+ * API name: {@code total_tokens} + */ + public final Builder totalTokens(int value) { + this.totalTokens = value; + return this; + } + + /** + * Breakdown of the tokens used in the prompt. Omitted when no details are + * available. + *

+ * API name: {@code prompt_tokens_details} + */ + public final Builder promptTokensDetails(@Nullable ChatCompletionPromptTokensDetails value) { + this.promptTokensDetails = value; + return this; + } + + /** + * Breakdown of the tokens used in the prompt. Omitted when no details are + * available. + *

+ * API name: {@code prompt_tokens_details} + */ + public final Builder promptTokensDetails( + Function> fn) { + return this.promptTokensDetails(fn.apply(new ChatCompletionPromptTokensDetails.Builder()).build()); + } + + /** + * Breakdown of the tokens used in the completion. Omitted when no details are + * available. + *

+ * API name: {@code completion_tokens_details} + */ + public final Builder completionTokensDetails(@Nullable ChatCompletionCompletionTokensDetails value) { + this.completionTokensDetails = value; + return this; + } + + /** + * Breakdown of the tokens used in the completion. Omitted when no details are + * available. + *

+ * API name: {@code completion_tokens_details} + */ + public final Builder completionTokensDetails( + Function> fn) { + return this.completionTokensDetails(fn.apply(new ChatCompletionCompletionTokensDetails.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ChatCompletionUsage}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ChatCompletionUsage build() { + _checkSingleUse(); + + return new ChatCompletionUsage(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ChatCompletionUsage} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ChatCompletionUsage::setupChatCompletionUsageDeserializer); + + protected static void setupChatCompletionUsageDeserializer(ObjectDeserializer op) { + + op.add(Builder::completionTokens, JsonpDeserializer.integerDeserializer(), "completion_tokens"); + op.add(Builder::promptTokens, JsonpDeserializer.integerDeserializer(), "prompt_tokens"); + op.add(Builder::totalTokens, JsonpDeserializer.integerDeserializer(), "total_tokens"); + op.add(Builder::promptTokensDetails, ChatCompletionPromptTokensDetails._DESERIALIZER, "prompt_tokens_details"); + op.add(Builder::completionTokensDetails, ChatCompletionCompletionTokensDetails._DESERIALIZER, + "completion_tokens_details"); + + } + +} 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 3fb814255c..8d3370d296 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 @@ -71,20 +71,19 @@ public ElasticsearchInferenceAsyncClient withTransportOptions(@Nullable Transpor // ----- Endpoint: inference.chat_completion_unified /** - * Perform chat completion inference on the service. + * Perform streaming chat completion inference on the service. *

* The chat completion inference API enables real-time responses for chat * completion tasks by delivering answers incrementally, reducing response times * during computation. It only works with the chat_completion task * type. *

- * NOTE: The chat_completion task type is only available within the - * _stream API and only supports streaming. The Chat completion inference API - * and the Stream inference API differ in their response structure and - * capabilities. The Chat completion inference API provides more comprehensive - * customization options through more fields and function calling support. To - * determine whether a given inference service supports this task type, please - * see the page for that service. + * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API and the Stream inference API + * differ in their response structure and capabilities. The Chat completion + * inference API provides more comprehensive customization options through more + * fields and function calling support. To determine whether a given inference + * service supports this task type, please see the page for that service. * * @see Documentation @@ -99,20 +98,19 @@ public CompletableFuture chatCompletionUnified(ChatCompletionUni } /** - * Perform chat completion inference on the service. + * Perform streaming chat completion inference on the service. *

* The chat completion inference API enables real-time responses for chat * completion tasks by delivering answers incrementally, reducing response times * during computation. It only works with the chat_completion task * type. *

- * NOTE: The chat_completion task type is only available within the - * _stream API and only supports streaming. The Chat completion inference API - * and the Stream inference API differ in their response structure and - * capabilities. The Chat completion inference API provides more comprehensive - * customization options through more fields and function calling support. To - * determine whether a given inference service supports this task type, please - * see the page for that service. + * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API and the Stream inference API + * differ in their response structure and capabilities. The Chat completion + * inference API provides more comprehensive customization options through more + * fields and function calling support. To determine whether a given inference + * service supports this task type, please see the page for that service. * * @param fn * a function that initializes a builder to create the @@ -425,6 +423,92 @@ public final CompletableFuture inference( return inference(fn.apply(new InferenceRequest.Builder()).build()); } + // ----- Endpoint: inference.non_streaming_chat_completion + + /** + * Perform non-streaming chat completion inference on the service. + *

+ * The chat completion inference API enables rich responses for chat completion + * tasks. It only works with the chat_completion task type. + *

+ * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API provides more comprehensive + * customization options through more fields and function calling support. To + * determine whether a given inference service supports this task type, please + * see the page for that service. + *

+ * These services support non-streaming chat completion inference: + *

+ * + * @see Documentation + * on elastic.co + */ + + public CompletableFuture nonStreamingChatCompletion( + NonStreamingChatCompletionRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) NonStreamingChatCompletionRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Perform non-streaming chat completion inference on the service. + *

+ * The chat completion inference API enables rich responses for chat completion + * tasks. It only works with the chat_completion task type. + *

+ * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API provides more comprehensive + * customization options through more fields and function calling support. To + * determine whether a given inference service supports this task type, please + * see the page for that service. + *

+ * These services support non-streaming chat completion inference: + *

    + *
  • AI21
  • + *
  • Azure OpenAI
  • + *
  • Deepseek
  • + *
  • Elastic
  • + *
  • FireworksAI
  • + *
  • Groq
  • + *
  • Huggingface
  • + *
  • IBMWatsonX
  • + *
  • Llama
  • + *
  • Mistral
  • + *
  • NVIDIA
  • + *
  • OpenAI
  • + *
  • OpenShiftAI
  • + *
+ * + * @param fn + * a function that initializes a builder to create the + * {@link NonStreamingChatCompletionRequest} + * @see Documentation + * on elastic.co + */ + + public final CompletableFuture nonStreamingChatCompletion( + Function> fn) { + return nonStreamingChatCompletion(fn.apply(new NonStreamingChatCompletionRequest.Builder()).build()); + } + // ----- Endpoint: inference.put /** 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 5294f2e515..8bc4356381 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 @@ -69,20 +69,19 @@ public ElasticsearchInferenceClient withTransportOptions(@Nullable TransportOpti // ----- Endpoint: inference.chat_completion_unified /** - * Perform chat completion inference on the service. + * Perform streaming chat completion inference on the service. *

* The chat completion inference API enables real-time responses for chat * completion tasks by delivering answers incrementally, reducing response times * during computation. It only works with the chat_completion task * type. *

- * NOTE: The chat_completion task type is only available within the - * _stream API and only supports streaming. The Chat completion inference API - * and the Stream inference API differ in their response structure and - * capabilities. The Chat completion inference API provides more comprehensive - * customization options through more fields and function calling support. To - * determine whether a given inference service supports this task type, please - * see the page for that service. + * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API and the Stream inference API + * differ in their response structure and capabilities. The Chat completion + * inference API provides more comprehensive customization options through more + * fields and function calling support. To determine whether a given inference + * service supports this task type, please see the page for that service. * * @see Documentation @@ -98,20 +97,19 @@ public BinaryResponse chatCompletionUnified(ChatCompletionUnifiedRequest request } /** - * Perform chat completion inference on the service. + * Perform streaming chat completion inference on the service. *

* The chat completion inference API enables real-time responses for chat * completion tasks by delivering answers incrementally, reducing response times * during computation. It only works with the chat_completion task * type. *

- * NOTE: The chat_completion task type is only available within the - * _stream API and only supports streaming. The Chat completion inference API - * and the Stream inference API differ in their response structure and - * capabilities. The Chat completion inference API provides more comprehensive - * customization options through more fields and function calling support. To - * determine whether a given inference service supports this task type, please - * see the page for that service. + * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API and the Stream inference API + * differ in their response structure and capabilities. The Chat completion + * inference API provides more comprehensive customization options through more + * fields and function calling support. To determine whether a given inference + * service supports this task type, please see the page for that service. * * @param fn * a function that initializes a builder to create the @@ -426,6 +424,93 @@ public final InferenceResponse inference(Function + * The chat completion inference API enables rich responses for chat completion + * tasks. It only works with the chat_completion task type. + *

+ * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API provides more comprehensive + * customization options through more fields and function calling support. To + * determine whether a given inference service supports this task type, please + * see the page for that service. + *

+ * These services support non-streaming chat completion inference: + *

+ * + * @see Documentation + * on elastic.co + */ + + public NonStreamingChatCompletionResponse nonStreamingChatCompletion(NonStreamingChatCompletionRequest request) + throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) NonStreamingChatCompletionRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Perform non-streaming chat completion inference on the service. + *

+ * The chat completion inference API enables rich responses for chat completion + * tasks. It only works with the chat_completion task type. + *

+ * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API provides more comprehensive + * customization options through more fields and function calling support. To + * determine whether a given inference service supports this task type, please + * see the page for that service. + *

+ * These services support non-streaming chat completion inference: + *

    + *
  • AI21
  • + *
  • Azure OpenAI
  • + *
  • Deepseek
  • + *
  • Elastic
  • + *
  • FireworksAI
  • + *
  • Groq
  • + *
  • Huggingface
  • + *
  • IBMWatsonX
  • + *
  • Llama
  • + *
  • Mistral
  • + *
  • NVIDIA
  • + *
  • OpenAI
  • + *
  • OpenShiftAI
  • + *
+ * + * @param fn + * a function that initializes a builder to create the + * {@link NonStreamingChatCompletionRequest} + * @see Documentation + * on elastic.co + */ + + public final NonStreamingChatCompletionResponse nonStreamingChatCompletion( + Function> fn) + throws IOException, ElasticsearchException { + return nonStreamingChatCompletion(fn.apply(new NonStreamingChatCompletionRequest.Builder()).build()); + } + // ----- Endpoint: inference.put /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/NonStreamingChatCompletionRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/NonStreamingChatCompletionRequest.java new file mode 100644 index 0000000000..c909a49a21 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/NonStreamingChatCompletionRequest.java @@ -0,0 +1,322 @@ +/* + * 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.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 jakarta.json.stream.JsonParser; +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.non_streaming_chat_completion.Request + +/** + * Perform non-streaming chat completion inference on the service. + *

+ * The chat completion inference API enables rich responses for chat completion + * tasks. It only works with the chat_completion task type. + *

+ * NOTE: The chat_completion task type supports both streaming and + * non-streaming. The Chat completion inference API provides more comprehensive + * customization options through more fields and function calling support. To + * determine whether a given inference service supports this task type, please + * see the page for that service. + *

+ * These services support non-streaming chat completion inference: + *

    + *
  • AI21
  • + *
  • Azure OpenAI
  • + *
  • Deepseek
  • + *
  • Elastic
  • + *
  • FireworksAI
  • + *
  • Groq
  • + *
  • Huggingface
  • + *
  • IBMWatsonX
  • + *
  • Llama
  • + *
  • Mistral
  • + *
  • NVIDIA
  • + *
  • OpenAI
  • + *
  • OpenShiftAI
  • + *
+ * + * @see API + * specification + */ +@JsonpDeserializable +public class NonStreamingChatCompletionRequest extends RequestBase implements JsonpSerializable { + private final String inferenceId; + + @Nullable + private final Time timeout; + + private final RequestChatCompletion chatCompletionRequest; + + // --------------------------------------------------------------------------------------------- + + private NonStreamingChatCompletionRequest(Builder builder) { + + this.inferenceId = ApiTypeHelper.requireNonNull(builder.inferenceId, this, "inferenceId"); + this.timeout = builder.timeout; + this.chatCompletionRequest = ApiTypeHelper.requireNonNull(builder.chatCompletionRequest, this, + "chatCompletionRequest"); + + } + + public static NonStreamingChatCompletionRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The inference Id + *

+ * API name: {@code inference_id} + */ + public final String inferenceId() { + return this.inferenceId; + } + + /** + * Specifies the amount of time to wait for the inference request to complete. + *

+ * API name: {@code timeout} + */ + @Nullable + public final Time timeout() { + return this.timeout; + } + + /** + * Required - Request body. + */ + public final RequestChatCompletion chatCompletionRequest() { + return this.chatCompletionRequest; + } + + /** + * Serialize this value to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + this.chatCompletionRequest.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link NonStreamingChatCompletionRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + private String inferenceId; + + @Nullable + private Time timeout; + + private RequestChatCompletion chatCompletionRequest; + + public Builder() { + } + private Builder(NonStreamingChatCompletionRequest instance) { + this.inferenceId = instance.inferenceId; + this.timeout = instance.timeout; + this.chatCompletionRequest = instance.chatCompletionRequest; + + } + /** + * Required - The inference Id + *

+ * API name: {@code inference_id} + */ + public final Builder inferenceId(String value) { + this.inferenceId = value; + return this; + } + + /** + * Specifies 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; + } + + /** + * Specifies 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()); + } + + /** + * Required - Request body. + */ + public final Builder chatCompletionRequest(RequestChatCompletion value) { + this.chatCompletionRequest = value; + return this; + } + + /** + * Required - Request body. + */ + public final Builder chatCompletionRequest( + Function> fn) { + return this.chatCompletionRequest(fn.apply(new RequestChatCompletion.Builder()).build()); + } + + @Override + public Builder withJson(JsonParser parser, JsonpMapper mapper) { + + @SuppressWarnings("unchecked") + RequestChatCompletion value = (RequestChatCompletion) RequestChatCompletion._DESERIALIZER + .deserialize(parser, mapper); + return this.chatCompletionRequest(value); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link NonStreamingChatCompletionRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public NonStreamingChatCompletionRequest build() { + _checkSingleUse(); + + return new NonStreamingChatCompletionRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + public static final JsonpDeserializer _DESERIALIZER = createNonStreamingChatCompletionRequestDeserializer(); + protected static JsonpDeserializer createNonStreamingChatCompletionRequestDeserializer() { + + JsonpDeserializer valueDeserializer = RequestChatCompletion._DESERIALIZER; + + return JsonpDeserializer.of(valueDeserializer.acceptedEvents(), (parser, mapper, event) -> new Builder() + .chatCompletionRequest(valueDeserializer.deserialize(parser, mapper, event)).build()); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code inference.non_streaming_chat_completion}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/inference.non_streaming_chat_completion", + + // 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("/chat_completion"); + 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, NonStreamingChatCompletionResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/NonStreamingChatCompletionResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/NonStreamingChatCompletionResponse.java new file mode 100644 index 0000000000..19ead75553 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/NonStreamingChatCompletionResponse.java @@ -0,0 +1,110 @@ +/* + * 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.non_streaming_chat_completion.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class NonStreamingChatCompletionResponse extends ChatCompletionInferenceResult { + // --------------------------------------------------------------------------------------------- + + private NonStreamingChatCompletionResponse(Builder builder) { + super(builder); + + } + + public static NonStreamingChatCompletionResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link NonStreamingChatCompletionResponse}. + */ + + public static class Builder extends ChatCompletionInferenceResult.AbstractBuilder + implements + ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link NonStreamingChatCompletionResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public NonStreamingChatCompletionResponse build() { + _checkSingleUse(); + + return new NonStreamingChatCompletionResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link NonStreamingChatCompletionResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + NonStreamingChatCompletionResponse::setupNonStreamingChatCompletionResponseDeserializer); + + protected static void setupNonStreamingChatCompletionResponseDeserializer( + ObjectDeserializer op) { + ChatCompletionInferenceResult.setupChatCompletionInferenceResultDeserializer(op); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DatafeedConfig.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DatafeedConfig.java index 3bbb6553ff..252118b658 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DatafeedConfig.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DatafeedConfig.java @@ -98,6 +98,9 @@ public class DatafeedConfig implements JsonpSerializable { @Nullable private final Integer maxEmptySearches; + @Nullable + private final Integer maxConsecutiveExtractionFailures; + @Nullable private final Query query; @@ -125,6 +128,7 @@ private DatafeedConfig(Builder builder) { this.projectRouting = builder.projectRouting; this.jobId = builder.jobId; this.maxEmptySearches = builder.maxEmptySearches; + this.maxConsecutiveExtractionFailures = builder.maxConsecutiveExtractionFailures; this.query = builder.query; this.queryDelay = builder.queryDelay; this.runtimeMappings = ApiTypeHelper.unmodifiable(builder.runtimeMappings); @@ -266,6 +270,23 @@ public final Integer maxEmptySearches() { return this.maxEmptySearches; } + /** + * The maximum number of consecutive real-time data extraction failures the + * datafeed tolerates before it automatically stops itself, leaving the + * associated job open. The consecutive-failure counter resets on any cycle that + * extracts successfully, including empty-data cycles. If not set, the threshold + * defaults to roughly one day's worth of searches based on the datafeed + * frequency (floored at 1). Set to -1 to disable + * auto-stop and retry indefinitely. Values of 0 or less than + * -1 are rejected. + *

+ * API name: {@code max_consecutive_extraction_failures} + */ + @Nullable + public final Integer maxConsecutiveExtractionFailures() { + return this.maxConsecutiveExtractionFailures; + } + /** * The Elasticsearch query domain-specific language (DSL). This value * corresponds to the query object in an Elasticsearch search POST body. All the @@ -397,6 +418,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("max_empty_searches"); generator.write(this.maxEmptySearches); + } + if (this.maxConsecutiveExtractionFailures != null) { + generator.writeKey("max_consecutive_extraction_failures"); + generator.write(this.maxConsecutiveExtractionFailures); + } if (this.query != null) { generator.writeKey("query"); @@ -480,6 +506,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private Integer maxEmptySearches; + @Nullable + private Integer maxConsecutiveExtractionFailures; + @Nullable private Query query; @@ -508,6 +537,7 @@ private Builder(DatafeedConfig instance) { this.projectRouting = instance.projectRouting; this.jobId = instance.jobId; this.maxEmptySearches = instance.maxEmptySearches; + this.maxConsecutiveExtractionFailures = instance.maxConsecutiveExtractionFailures; this.query = instance.query; this.queryDelay = instance.queryDelay; this.runtimeMappings = instance.runtimeMappings; @@ -756,6 +786,23 @@ public final Builder maxEmptySearches(@Nullable Integer value) { return this; } + /** + * The maximum number of consecutive real-time data extraction failures the + * datafeed tolerates before it automatically stops itself, leaving the + * associated job open. The consecutive-failure counter resets on any cycle that + * extracts successfully, including empty-data cycles. If not set, the threshold + * defaults to roughly one day's worth of searches based on the datafeed + * frequency (floored at 1). Set to -1 to disable + * auto-stop and retry indefinitely. Values of 0 or less than + * -1 are rejected. + *

+ * API name: {@code max_consecutive_extraction_failures} + */ + public final Builder maxConsecutiveExtractionFailures(@Nullable Integer value) { + this.maxConsecutiveExtractionFailures = value; + return this; + } + /** * The Elasticsearch query domain-specific language (DSL). This value * corresponds to the query object in an Elasticsearch search POST body. All the @@ -958,6 +1005,8 @@ protected static void setupDatafeedConfigDeserializer(ObjectDeserializerfrequency (floored at 1). Set to -1 to disable + * auto-stop and retry indefinitely. Values of 0 or less than + * -1 are rejected. + *

+ * API name: {@code max_consecutive_extraction_failures} + */ + @Nullable + public final Integer maxConsecutiveExtractionFailures() { + return this.maxConsecutiveExtractionFailures; + } + /** * If a real-time datafeed has never seen any data (including during any initial * training period), it automatically stops and closes the associated job after @@ -500,6 +521,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("job_id"); generator.write(this.jobId); + } + if (this.maxConsecutiveExtractionFailures != null) { + generator.writeKey("max_consecutive_extraction_failures"); + generator.write(this.maxConsecutiveExtractionFailures); + } if (this.maxEmptySearches != null) { generator.writeKey("max_empty_searches"); @@ -598,6 +624,9 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private String jobId; + @Nullable + private Integer maxConsecutiveExtractionFailures; + @Nullable private Integer maxEmptySearches; @@ -635,6 +664,7 @@ private Builder(PutDatafeedRequest instance) { this.indices = instance.indices; this.indicesOptions = instance.indicesOptions; this.jobId = instance.jobId; + this.maxConsecutiveExtractionFailures = instance.maxConsecutiveExtractionFailures; this.maxEmptySearches = instance.maxEmptySearches; this.projectRouting = instance.projectRouting; this.query = instance.query; @@ -945,6 +975,23 @@ public final Builder jobId(@Nullable String value) { return this; } + /** + * The maximum number of consecutive real-time data extraction failures the + * datafeed tolerates before it automatically stops itself, leaving the + * associated job open. The consecutive-failure counter resets on any cycle that + * extracts successfully, including empty-data cycles. If not set, the threshold + * defaults to roughly one day's worth of searches based on the datafeed + * frequency (floored at 1). Set to -1 to disable + * auto-stop and retry indefinitely. Values of 0 or less than + * -1 are rejected. + *

+ * API name: {@code max_consecutive_extraction_failures} + */ + public final Builder maxConsecutiveExtractionFailures(@Nullable Integer value) { + this.maxConsecutiveExtractionFailures = value; + return this; + } + /** * If a real-time datafeed has never seen any data (including during any initial * training period), it automatically stops and closes the associated job after @@ -1176,6 +1223,8 @@ protected static void setupPutDatafeedRequestDeserializer(ObjectDeserializer @Nullable private Integer maxEmptySearches; + @Nullable + private Integer maxConsecutiveExtractionFailures; + private Query query; private Time queryDelay; @@ -579,6 +599,14 @@ public final Builder maxEmptySearches(@Nullable Integer value) { return this; } + /** + * API name: {@code max_consecutive_extraction_failures} + */ + public final Builder maxConsecutiveExtractionFailures(@Nullable Integer value) { + this.maxConsecutiveExtractionFailures = value; + return this; + } + /** * Required - API name: {@code query} */ @@ -738,6 +766,8 @@ protected static void setupPutDatafeedResponseDeserializer(ObjectDeserializerfrequency (floored at 1). Set to -1 to disable + * auto-stop and retry indefinitely. Values of 0 or less than + * -1 are rejected. + *

+ * API name: {@code max_consecutive_extraction_failures} + */ + @Nullable + public final Integer maxConsecutiveExtractionFailures() { + return this.maxConsecutiveExtractionFailures; + } + /** * If a real-time datafeed has never seen any data (including during any initial * training period), it automatically stops and closes the associated job after @@ -488,6 +509,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("job_id"); generator.write(this.jobId); + } + if (this.maxConsecutiveExtractionFailures != null) { + generator.writeKey("max_consecutive_extraction_failures"); + generator.write(this.maxConsecutiveExtractionFailures); + } if (this.maxEmptySearches != null) { generator.writeKey("max_empty_searches"); @@ -586,6 +612,9 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private String jobId; + @Nullable + private Integer maxConsecutiveExtractionFailures; + @Nullable private Integer maxEmptySearches; @@ -623,6 +652,7 @@ private Builder(UpdateDatafeedRequest instance) { this.indices = instance.indices; this.indicesOptions = instance.indicesOptions; this.jobId = instance.jobId; + this.maxConsecutiveExtractionFailures = instance.maxConsecutiveExtractionFailures; this.maxEmptySearches = instance.maxEmptySearches; this.projectRouting = instance.projectRouting; this.query = instance.query; @@ -924,6 +954,23 @@ public final Builder jobId(@Nullable String value) { return this; } + /** + * The maximum number of consecutive real-time data extraction failures the + * datafeed tolerates before it automatically stops itself, leaving the + * associated job open. The consecutive-failure counter resets on any cycle that + * extracts successfully, including empty-data cycles. If not set, the threshold + * defaults to roughly one day's worth of searches based on the datafeed + * frequency (floored at 1). Set to -1 to disable + * auto-stop and retry indefinitely. Values of 0 or less than + * -1 are rejected. + *

+ * API name: {@code max_consecutive_extraction_failures} + */ + public final Builder maxConsecutiveExtractionFailures(@Nullable Integer value) { + this.maxConsecutiveExtractionFailures = value; + return this; + } + /** * If a real-time datafeed has never seen any data (including during any initial * training period), it automatically stops and closes the associated job after @@ -1169,6 +1216,8 @@ protected static void setupUpdateDatafeedRequestDeserializer(ObjectDeserializer< "indexes"); op.add(Builder::indicesOptions, IndicesOptions._DESERIALIZER, "indices_options"); op.add(Builder::jobId, JsonpDeserializer.stringDeserializer(), "job_id"); + op.add(Builder::maxConsecutiveExtractionFailures, JsonpDeserializer.integerDeserializer(), + "max_consecutive_extraction_failures"); op.add(Builder::maxEmptySearches, JsonpDeserializer.integerDeserializer(), "max_empty_searches"); op.add(Builder::projectRouting, JsonpDeserializer.stringDeserializer(), "project_routing"); op.add(Builder::query, Query._DESERIALIZER, "query"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/UpdateDatafeedResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/UpdateDatafeedResponse.java index 34e6fcb81b..dc1728fa1d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/UpdateDatafeedResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/UpdateDatafeedResponse.java @@ -95,6 +95,9 @@ public class UpdateDatafeedResponse implements JsonpSerializable { @Nullable private final Integer maxEmptySearches; + @Nullable + private final Integer maxConsecutiveExtractionFailures; + private final Query query; private final Time queryDelay; @@ -122,6 +125,7 @@ private UpdateDatafeedResponse(Builder builder) { this.indicesOptions = builder.indicesOptions; this.jobId = ApiTypeHelper.requireNonNull(builder.jobId, this, "jobId"); this.maxEmptySearches = builder.maxEmptySearches; + this.maxConsecutiveExtractionFailures = builder.maxConsecutiveExtractionFailures; this.query = ApiTypeHelper.requireNonNull(builder.query, this, "query"); this.queryDelay = ApiTypeHelper.requireNonNull(builder.queryDelay, this, "queryDelay"); this.runtimeMappings = ApiTypeHelper.unmodifiable(builder.runtimeMappings); @@ -219,6 +223,14 @@ public final Integer maxEmptySearches() { return this.maxEmptySearches; } + /** + * API name: {@code max_consecutive_extraction_failures} + */ + @Nullable + public final Integer maxConsecutiveExtractionFailures() { + return this.maxConsecutiveExtractionFailures; + } + /** * Required - API name: {@code query} */ @@ -333,6 +345,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("max_empty_searches"); generator.write(this.maxEmptySearches); + } + if (this.maxConsecutiveExtractionFailures != null) { + generator.writeKey("max_consecutive_extraction_failures"); + generator.write(this.maxConsecutiveExtractionFailures); + } generator.writeKey("query"); this.query.serialize(generator, mapper); @@ -413,6 +430,9 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Integer maxEmptySearches; + @Nullable + private Integer maxConsecutiveExtractionFailures; + private Query query; private Time queryDelay; @@ -606,6 +626,14 @@ public final Builder maxEmptySearches(@Nullable Integer value) { return this; } + /** + * API name: {@code max_consecutive_extraction_failures} + */ + public final Builder maxConsecutiveExtractionFailures(@Nullable Integer value) { + this.maxConsecutiveExtractionFailures = value; + return this; + } + /** * Required - API name: {@code query} */ @@ -766,6 +794,8 @@ protected static void setupUpdateDatafeedResponseDeserializer( op.add(Builder::indicesOptions, IndicesOptions._DESERIALIZER, "indices_options"); op.add(Builder::jobId, JsonpDeserializer.stringDeserializer(), "job_id"); op.add(Builder::maxEmptySearches, JsonpDeserializer.integerDeserializer(), "max_empty_searches"); + op.add(Builder::maxConsecutiveExtractionFailures, JsonpDeserializer.integerDeserializer(), + "max_consecutive_extraction_failures"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::queryDelay, Time._DESERIALIZER, "query_delay"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer(RuntimeField._DESERIALIZER), diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ClusterPrivilege.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ClusterPrivilege.java index 334a42f354..8a939f6e74 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ClusterPrivilege.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ClusterPrivilege.java @@ -50,6 +50,8 @@ public enum ClusterPrivilege implements JsonEnum { CancelTask("cancel_task"), + CloneApiKey("clone_api_key"), + CreateSnapshot("create_snapshot"), CrossClusterReplication("cross_cluster_replication"), diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/CreateServiceTokenRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/CreateServiceTokenRequest.java index c3d04edf80..a50a35447c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/CreateServiceTokenRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/CreateServiceTokenRequest.java @@ -59,7 +59,10 @@ * Create a service account token. *

* Create a service accounts token for access without requiring basic - * authentication. + * authentication. This route serves both kinds of service account, but the + * privileges differ: manage_service_account authorizes tokens of + * built-in accounts in the elastic namespace only, and tokens of a + * user-managed account require manage_security. *

* NOTE: Service account tokens never expire. You must actively delete them if * they are no longer needed. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteServiceTokenRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteServiceTokenRequest.java index 6097b24311..977b40e993 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteServiceTokenRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteServiceTokenRequest.java @@ -58,7 +58,11 @@ /** * Delete service account tokens. *

- * Delete service account tokens for a service in a specified namespace. + * Delete service account tokens for a service in a specified namespace. This + * route serves both kinds of service account, but the privileges differ: + * manage_service_account authorizes tokens of built-in accounts in + * the elastic namespace only, and tokens of a user-managed account + * require manage_security. *

* IMPORTANT: On Serverless, non-operator users can delete tokens for only * elastic/fleet-server and diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteUserManagedServiceAccountRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteUserManagedServiceAccountRequest.java new file mode 100644 index 0000000000..9aec599d84 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteUserManagedServiceAccountRequest.java @@ -0,0 +1,324 @@ +/* + * 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.Refresh; +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.Boolean; +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: security.delete_user_managed_service_account.Request + +/** + * Delete user-managed service accounts. + *

+ * Delete a service account from a namespace of your own. + *

+ * Deleting an account that still has service tokens is rejected unless + * force is true. A forced delete leaves the tokens + * behind: they cannot authenticate while no account of that name exists, and + * recreating the account is rejected until they are deleted. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. A name that no user-managed service + * account could have is rejected rather than reported as not found. The + * manage_service_account privilege does not authorize this API. + * + * @see API + * specification + */ + +public class DeleteUserManagedServiceAccountRequest extends RequestBase { + @Nullable + private final Boolean force; + + private final String namespace; + + @Nullable + private final Refresh refresh; + + private final String service; + + // --------------------------------------------------------------------------------------------- + + private DeleteUserManagedServiceAccountRequest(Builder builder) { + + this.force = builder.force; + this.namespace = ApiTypeHelper.requireNonNull(builder.namespace, this, "namespace"); + this.refresh = builder.refresh; + this.service = ApiTypeHelper.requireNonNull(builder.service, this, "service"); + + } + + public static DeleteUserManagedServiceAccountRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * If false (the default), deleting a service account that still + * has service tokens is rejected. If true, the account is deleted + * and its tokens are left in place. + *

+ * API name: {@code force} + */ + @Nullable + public final Boolean force() { + return this.force; + } + + /** + * Required - The namespace, which is a top-level grouping of service accounts. + * It must start with a letter or digit and can contain only letters, digits, + * hyphens, and underscores, up to a maximum of 128 characters. It cannot be + * elastic, which is reserved for built-in service accounts. + *

+ * API name: {@code namespace} + */ + public final String namespace() { + return this.namespace; + } + + /** + * If wait_for (the default) then wait for a refresh to make this + * operation visible to search, if true then refresh the affected + * shards to make this operation visible to search, if false then + * do nothing with refreshes. + *

+ * API name: {@code refresh} + */ + @Nullable + public final Refresh refresh() { + return this.refresh; + } + + /** + * Required - The service name. It must start with a letter or digit and can + * contain only letters, digits, hyphens, and underscores, up to a maximum of + * 128 characters. + *

+ * API name: {@code service} + */ + public final String service() { + return this.service; + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DeleteUserManagedServiceAccountRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private Boolean force; + + private String namespace; + + @Nullable + private Refresh refresh; + + private String service; + + public Builder() { + } + private Builder(DeleteUserManagedServiceAccountRequest instance) { + this.force = instance.force; + this.namespace = instance.namespace; + this.refresh = instance.refresh; + this.service = instance.service; + + } + /** + * If false (the default), deleting a service account that still + * has service tokens is rejected. If true, the account is deleted + * and its tokens are left in place. + *

+ * API name: {@code force} + */ + public final Builder force(@Nullable Boolean value) { + this.force = value; + return this; + } + + /** + * Required - The namespace, which is a top-level grouping of service accounts. + * It must start with a letter or digit and can contain only letters, digits, + * hyphens, and underscores, up to a maximum of 128 characters. It cannot be + * elastic, which is reserved for built-in service accounts. + *

+ * API name: {@code namespace} + */ + public final Builder namespace(String value) { + this.namespace = value; + return this; + } + + /** + * If wait_for (the default) then wait for a refresh to make this + * operation visible to search, if true then refresh the affected + * shards to make this operation visible to search, if false then + * do nothing with refreshes. + *

+ * API name: {@code refresh} + */ + public final Builder refresh(@Nullable Refresh value) { + this.refresh = value; + return this; + } + + /** + * Required - The service name. It must start with a letter or digit and can + * contain only letters, digits, hyphens, and underscores, up to a maximum of + * 128 characters. + *

+ * API name: {@code service} + */ + public final Builder service(String value) { + this.service = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DeleteUserManagedServiceAccountRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DeleteUserManagedServiceAccountRequest build() { + _checkSingleUse(); + + return new DeleteUserManagedServiceAccountRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code security.delete_user_managed_service_account}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/security.delete_user_managed_service_account", + + // Request method + request -> { + return "DELETE"; + + }, + + // Request path + request -> { + final int _service = 1 << 0; + final int _namespace = 1 << 1; + + int propsSet = 0; + + propsSet |= _service; + propsSet |= _namespace; + + if (propsSet == (_namespace | _service)) { + StringBuilder buf = new StringBuilder(); + buf.append("/_security"); + buf.append("/service"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.namespace, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.service, buf); + return buf.toString(); + } + throw SimpleEndpoint.noPathTemplateFound("path"); + + }, + + // Path parameters + request -> { + Map params = new HashMap<>(); + final int _service = 1 << 0; + final int _namespace = 1 << 1; + + int propsSet = 0; + + propsSet |= _service; + propsSet |= _namespace; + + if (propsSet == (_namespace | _service)) { + params.put("namespace", request.namespace); + params.put("service", request.service); + } + return params; + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.refresh != null) { + params.put("refresh", request.refresh.jsonValue()); + } + if (request.force != null) { + params.put("force", String.valueOf(request.force)); + } + return params; + + }, SimpleEndpoint.emptyMap(), false, DeleteUserManagedServiceAccountResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteUserManagedServiceAccountResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteUserManagedServiceAccountResponse.java new file mode 100644 index 0000000000..1cd2d8e27f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DeleteUserManagedServiceAccountResponse.java @@ -0,0 +1,166 @@ +/* + * 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.Boolean; +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: security.delete_user_managed_service_account.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DeleteUserManagedServiceAccountResponse implements JsonpSerializable { + private final boolean found; + + // --------------------------------------------------------------------------------------------- + + private DeleteUserManagedServiceAccountResponse(Builder builder) { + + this.found = ApiTypeHelper.requireNonNull(builder.found, this, "found", false); + + } + + public static DeleteUserManagedServiceAccountResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - If the service account is successfully deleted, the request + * returns {"found": true}. Otherwise, the response will + * have status code 404 and found is set to false. + *

+ * API name: {@code found} + */ + public final boolean found() { + return this.found; + } + + /** + * 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("found"); + generator.write(this.found); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DeleteUserManagedServiceAccountResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Boolean found; + + /** + * Required - If the service account is successfully deleted, the request + * returns {"found": true}. Otherwise, the response will + * have status code 404 and found is set to false. + *

+ * API name: {@code found} + */ + public final Builder found(boolean value) { + this.found = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DeleteUserManagedServiceAccountResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DeleteUserManagedServiceAccountResponse build() { + _checkSingleUse(); + + return new DeleteUserManagedServiceAccountResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DeleteUserManagedServiceAccountResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + DeleteUserManagedServiceAccountResponse::setupDeleteUserManagedServiceAccountResponseDeserializer); + + protected static void setupDeleteUserManagedServiceAccountResponseDeserializer( + ObjectDeserializer op) { + + op.add(Builder::found, JsonpDeserializer.booleanDeserializer(), "found"); + + } + +} 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 1c6940b488..4a1eafd078 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 @@ -848,7 +848,10 @@ public final CompletableFuture createCrossClus * Create a service account token. *

* Create a service accounts token for access without requiring basic - * authentication. + * authentication. This route serves both kinds of service account, but the + * privileges differ: manage_service_account authorizes tokens of + * built-in accounts in the elastic namespace only, and tokens of a + * user-managed account require manage_security. *

* NOTE: Service account tokens never expire. You must actively delete them if * they are no longer needed. @@ -874,7 +877,10 @@ public CompletableFuture createServiceToken(CreateSe * Create a service account token. *

* Create a service accounts token for access without requiring basic - * authentication. + * authentication. This route serves both kinds of service account, but the + * privileges differ: manage_service_account authorizes tokens of + * built-in accounts in the elastic namespace only, and tokens of a + * user-managed account require manage_security. *

* NOTE: Service account tokens never expire. You must actively delete them if * they are no longer needed. @@ -1104,7 +1110,11 @@ public final CompletableFuture deleteRoleMapping( /** * Delete service account tokens. *

- * Delete service account tokens for a service in a specified namespace. + * Delete service account tokens for a service in a specified namespace. This + * route serves both kinds of service account, but the privileges differ: + * manage_service_account authorizes tokens of built-in accounts in + * the elastic namespace only, and tokens of a user-managed account + * require manage_security. *

* IMPORTANT: On Serverless, non-operator users can delete tokens for only * elastic/fleet-server and @@ -1126,7 +1136,11 @@ public CompletableFuture deleteServiceToken(DeleteSe /** * Delete service account tokens. *

- * Delete service account tokens for a service in a specified namespace. + * Delete service account tokens for a service in a specified namespace. This + * route serves both kinds of service account, but the privileges differ: + * manage_service_account authorizes tokens of built-in accounts in + * the elastic namespace only, and tokens of a user-managed account + * require manage_security. *

* IMPORTANT: On Serverless, non-operator users can delete tokens for only * elastic/fleet-server and @@ -1183,6 +1197,64 @@ public final CompletableFuture deleteUser( return deleteUser(fn.apply(new DeleteUserRequest.Builder()).build()); } + // ----- Endpoint: security.delete_user_managed_service_account + + /** + * Delete user-managed service accounts. + *

+ * Delete a service account from a namespace of your own. + *

+ * Deleting an account that still has service tokens is rejected unless + * force is true. A forced delete leaves the tokens + * behind: they cannot authenticate while no account of that name exists, and + * recreating the account is rejected until they are deleted. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. A name that no user-managed service + * account could have is rejected rather than reported as not found. The + * manage_service_account privilege does not authorize this API. + * + * @see Documentation + * on elastic.co + */ + + public CompletableFuture deleteUserManagedServiceAccount( + DeleteUserManagedServiceAccountRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) DeleteUserManagedServiceAccountRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Delete user-managed service accounts. + *

+ * Delete a service account from a namespace of your own. + *

+ * Deleting an account that still has service tokens is rejected unless + * force is true. A forced delete leaves the tokens + * behind: they cannot authenticate while no account of that name exists, and + * recreating the account is rejected until they are deleted. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. A name that no user-managed service + * account could have is rejected rather than reported as not found. The + * manage_service_account privilege does not authorize this API. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteUserManagedServiceAccountRequest} + * @see Documentation + * on elastic.co + */ + + public final CompletableFuture deleteUserManagedServiceAccount( + Function> fn) { + return deleteUserManagedServiceAccount(fn.apply(new DeleteUserManagedServiceAccountRequest.Builder()).build()); + } + // ----- Endpoint: security.disable_user /** @@ -1700,9 +1772,14 @@ public CompletableFuture getRoleMapping() { * Get service accounts. *

* Get a list of service accounts that match the provided path parameters. + * Built-in service accounts ship with Elasticsearch in the elastic + * namespace; user-managed service accounts are created with the put + * user-managed service account API. *

- * NOTE: Currently, only the elastic/fleet-server service account - * is available. + * NOTE: When type is omitted, a request without a namespace + * reports built-in accounts only, which preserves the response of a + * whole-cluster listing. A request scoped to a namespace reports both kinds, so + * an account you created is found without naming its kind. * * @see Documentation @@ -1720,9 +1797,14 @@ public CompletableFuture getServiceAccounts(GetServi * Get service accounts. *

* Get a list of service accounts that match the provided path parameters. + * Built-in service accounts ship with Elasticsearch in the elastic + * namespace; user-managed service accounts are created with the put + * user-managed service account API. *

- * NOTE: Currently, only the elastic/fleet-server service account - * is available. + * NOTE: When type is omitted, a request without a namespace + * reports built-in accounts only, which preserves the response of a + * whole-cluster listing. A request scoped to a namespace reports both kinds, so + * an account you created is found without naming its kind. * * @param fn * a function that initializes a builder to create the @@ -1741,9 +1823,14 @@ public final CompletableFuture getServiceAccounts( * Get service accounts. *

* Get a list of service accounts that match the provided path parameters. + * Built-in service accounts ship with Elasticsearch in the elastic + * namespace; user-managed service accounts are created with the put + * user-managed service account API. *

- * NOTE: Currently, only the elastic/fleet-server service account - * is available. + * NOTE: When type is omitted, a request without a namespace + * reports built-in accounts only, which preserves the response of a + * whole-cluster listing. A request scoped to a namespace reports both kinds, so + * an account you created is found without naming its kind. * * @see Documentation @@ -3058,6 +3145,64 @@ public final CompletableFuture putUser( return putUser(fn.apply(new PutUserRequest.Builder()).build()); } + // ----- Endpoint: security.put_user_managed_service_account + + /** + * Create user-managed service accounts. + *

+ * Create a service account in a namespace of your own, or replace one that + * already exists. A replacement is not a partial update: every write applies + * the defaults, so an account that was disabled and is then written again + * without enabled comes back enabled. + *

+ * Creating an account whose name still has leftover service tokens is rejected. + * Delete those tokens first. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. The + * manage_service_account privilege does not authorize this API. + * + * @see Documentation + * on elastic.co + */ + + public CompletableFuture putUserManagedServiceAccount( + PutUserManagedServiceAccountRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) PutUserManagedServiceAccountRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Create user-managed service accounts. + *

+ * Create a service account in a namespace of your own, or replace one that + * already exists. A replacement is not a partial update: every write applies + * the defaults, so an account that was disabled and is then written again + * without enabled comes back enabled. + *

+ * Creating an account whose name still has leftover service tokens is rejected. + * Delete those tokens first. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. The + * manage_service_account privilege does not authorize this API. + * + * @param fn + * a function that initializes a builder to create the + * {@link PutUserManagedServiceAccountRequest} + * @see Documentation + * on elastic.co + */ + + public final CompletableFuture putUserManagedServiceAccount( + Function> fn) { + return putUserManagedServiceAccount(fn.apply(new PutUserManagedServiceAccountRequest.Builder()).build()); + } + // ----- Endpoint: security.query_api_keys /** 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 933c3ecb0f..cc9f7617d0 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 @@ -866,7 +866,10 @@ public final CreateCrossClusterApiKeyResponse createCrossClusterApiKey( * Create a service account token. *

* Create a service accounts token for access without requiring basic - * authentication. + * authentication. This route serves both kinds of service account, but the + * privileges differ: manage_service_account authorizes tokens of + * built-in accounts in the elastic namespace only, and tokens of a + * user-managed account require manage_security. *

* NOTE: Service account tokens never expire. You must actively delete them if * they are no longer needed. @@ -893,7 +896,10 @@ public CreateServiceTokenResponse createServiceToken(CreateServiceTokenRequest r * Create a service account token. *

* Create a service accounts token for access without requiring basic - * authentication. + * authentication. This route serves both kinds of service account, but the + * privileges differ: manage_service_account authorizes tokens of + * built-in accounts in the elastic namespace only, and tokens of a + * user-managed account require manage_security. *

* NOTE: Service account tokens never expire. You must actively delete them if * they are no longer needed. @@ -1129,7 +1135,11 @@ public final DeleteRoleMappingResponse deleteRoleMapping( /** * Delete service account tokens. *

- * Delete service account tokens for a service in a specified namespace. + * Delete service account tokens for a service in a specified namespace. This + * route serves both kinds of service account, but the privileges differ: + * manage_service_account authorizes tokens of built-in accounts in + * the elastic namespace only, and tokens of a user-managed account + * require manage_security. *

* IMPORTANT: On Serverless, non-operator users can delete tokens for only * elastic/fleet-server and @@ -1152,7 +1162,11 @@ public DeleteServiceTokenResponse deleteServiceToken(DeleteServiceTokenRequest r /** * Delete service account tokens. *

- * Delete service account tokens for a service in a specified namespace. + * Delete service account tokens for a service in a specified namespace. This + * route serves both kinds of service account, but the privileges differ: + * manage_service_account authorizes tokens of built-in accounts in + * the elastic namespace only, and tokens of a user-managed account + * require manage_security. *

* IMPORTANT: On Serverless, non-operator users can delete tokens for only * elastic/fleet-server and @@ -1210,6 +1224,65 @@ public final DeleteUserResponse deleteUser(Function + * Delete a service account from a namespace of your own. + *

+ * Deleting an account that still has service tokens is rejected unless + * force is true. A forced delete leaves the tokens + * behind: they cannot authenticate while no account of that name exists, and + * recreating the account is rejected until they are deleted. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. A name that no user-managed service + * account could have is rejected rather than reported as not found. The + * manage_service_account privilege does not authorize this API. + * + * @see Documentation + * on elastic.co + */ + + public DeleteUserManagedServiceAccountResponse deleteUserManagedServiceAccount( + DeleteUserManagedServiceAccountRequest request) throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) DeleteUserManagedServiceAccountRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Delete user-managed service accounts. + *

+ * Delete a service account from a namespace of your own. + *

+ * Deleting an account that still has service tokens is rejected unless + * force is true. A forced delete leaves the tokens + * behind: they cannot authenticate while no account of that name exists, and + * recreating the account is rejected until they are deleted. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. A name that no user-managed service + * account could have is rejected rather than reported as not found. The + * manage_service_account privilege does not authorize this API. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteUserManagedServiceAccountRequest} + * @see Documentation + * on elastic.co + */ + + public final DeleteUserManagedServiceAccountResponse deleteUserManagedServiceAccount( + Function> fn) + throws IOException, ElasticsearchException { + return deleteUserManagedServiceAccount(fn.apply(new DeleteUserManagedServiceAccountRequest.Builder()).build()); + } + // ----- Endpoint: security.disable_user /** @@ -1736,9 +1809,14 @@ public GetRoleMappingResponse getRoleMapping() throws IOException, Elasticsearch * Get service accounts. *

* Get a list of service accounts that match the provided path parameters. + * Built-in service accounts ship with Elasticsearch in the elastic + * namespace; user-managed service accounts are created with the put + * user-managed service account API. *

- * NOTE: Currently, only the elastic/fleet-server service account - * is available. + * NOTE: When type is omitted, a request without a namespace + * reports built-in accounts only, which preserves the response of a + * whole-cluster listing. A request scoped to a namespace reports both kinds, so + * an account you created is found without naming its kind. * * @see Documentation @@ -1757,9 +1835,14 @@ public GetServiceAccountsResponse getServiceAccounts(GetServiceAccountsRequest r * Get service accounts. *

* Get a list of service accounts that match the provided path parameters. + * Built-in service accounts ship with Elasticsearch in the elastic + * namespace; user-managed service accounts are created with the put + * user-managed service account API. *

- * NOTE: Currently, only the elastic/fleet-server service account - * is available. + * NOTE: When type is omitted, a request without a namespace + * reports built-in accounts only, which preserves the response of a + * whole-cluster listing. A request scoped to a namespace reports both kinds, so + * an account you created is found without naming its kind. * * @param fn * a function that initializes a builder to create the @@ -1779,9 +1862,14 @@ public final GetServiceAccountsResponse getServiceAccounts( * Get service accounts. *

* Get a list of service accounts that match the provided path parameters. + * Built-in service accounts ship with Elasticsearch in the elastic + * namespace; user-managed service accounts are created with the put + * user-managed service account API. *

- * NOTE: Currently, only the elastic/fleet-server service account - * is available. + * NOTE: When type is omitted, a request without a namespace + * reports built-in accounts only, which preserves the response of a + * whole-cluster listing. A request scoped to a namespace reports both kinds, so + * an account you created is found without naming its kind. * * @see Documentation @@ -3116,6 +3204,65 @@ public final PutUserResponse putUser(Function + * Create a service account in a namespace of your own, or replace one that + * already exists. A replacement is not a partial update: every write applies + * the defaults, so an account that was disabled and is then written again + * without enabled comes back enabled. + *

+ * Creating an account whose name still has leftover service tokens is rejected. + * Delete those tokens first. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. The + * manage_service_account privilege does not authorize this API. + * + * @see Documentation + * on elastic.co + */ + + public PutUserManagedServiceAccountResponse putUserManagedServiceAccount( + PutUserManagedServiceAccountRequest request) throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) PutUserManagedServiceAccountRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Create user-managed service accounts. + *

+ * Create a service account in a namespace of your own, or replace one that + * already exists. A replacement is not a partial update: every write applies + * the defaults, so an account that was disabled and is then written again + * without enabled comes back enabled. + *

+ * Creating an account whose name still has leftover service tokens is rejected. + * Delete those tokens first. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. The + * manage_service_account privilege does not authorize this API. + * + * @param fn + * a function that initializes a builder to create the + * {@link PutUserManagedServiceAccountRequest} + * @see Documentation + * on elastic.co + */ + + public final PutUserManagedServiceAccountResponse putUserManagedServiceAccount( + Function> fn) + throws IOException, ElasticsearchException { + return putUserManagedServiceAccount(fn.apply(new PutUserManagedServiceAccountRequest.Builder()).build()); + } + // ----- Endpoint: security.query_api_keys /** 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 3314589120..c1118977e7 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 @@ -21,20 +21,23 @@ import co.elastic.clients.elasticsearch._types.ErrorResponse; import co.elastic.clients.elasticsearch._types.RequestBase; +import co.elastic.clients.elasticsearch.security.get_service_accounts.ServiceAccountType; 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.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; +import java.util.stream.Collectors; import javax.annotation.Nullable; //---------------------------------------------------------------- @@ -58,9 +61,14 @@ * Get service accounts. *

* Get a list of service accounts that match the provided path parameters. + * Built-in service accounts ship with Elasticsearch in the elastic + * namespace; user-managed service accounts are created with the put + * user-managed service account API. *

- * NOTE: Currently, only the elastic/fleet-server service account - * is available. + * NOTE: When type is omitted, a request without a namespace + * reports built-in accounts only, which preserves the response of a + * whole-cluster listing. A request scoped to a namespace reports both kinds, so + * an account you created is found without naming its kind. * * @see API @@ -74,12 +82,15 @@ public class GetServiceAccountsRequest extends RequestBase { @Nullable private final String service; + private final List type; + // --------------------------------------------------------------------------------------------- private GetServiceAccountsRequest(Builder builder) { this.namespace = builder.namespace; this.service = builder.service; + this.type = ApiTypeHelper.unmodifiable(builder.type); } @@ -110,6 +121,17 @@ public final String service() { return this.service; } + /** + * A comma-separated list of the kinds of service account to return. If it is + * omitted, it defaults to built_in when no namespace is given and + * to built_in,user_managed otherwise. + *

+ * API name: {@code type} + */ + public final List type() { + return this.type; + } + // --------------------------------------------------------------------------------------------- /** @@ -125,11 +147,15 @@ public static class Builder extends RequestBase.AbstractBuilder @Nullable private String service; + @Nullable + private List type; + public Builder() { } private Builder(GetServiceAccountsRequest instance) { this.namespace = instance.namespace; this.service = instance.service; + this.type = instance.type; } /** @@ -155,6 +181,34 @@ public final Builder service(@Nullable String value) { return this; } + /** + * A comma-separated list of the kinds of service account to return. If it is + * omitted, it defaults to built_in when no namespace is given and + * to built_in,user_managed otherwise. + *

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

+ * Adds all elements of list to type. + */ + public final Builder type(List list) { + this.type = _listAddAll(this.type, list); + return this; + } + + /** + * A comma-separated list of the kinds of service account to return. If it is + * omitted, it defaults to built_in when no namespace is given and + * to built_in,user_managed otherwise. + *

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

+ * Adds one or more values to type. + */ + public final Builder type(ServiceAccountType value, ServiceAccountType... values) { + this.type = _listAdd(this.type, value, values); + return this; + } + @Override protected Builder self() { return this; @@ -260,7 +314,12 @@ public Builder rebuild() { // Request parameters request -> { - return Collections.emptyMap(); + Map params = new HashMap<>(); + if (ApiTypeHelper.isDefined(request.type)) { + params.put("type", request.type.stream().map(v -> v.jsonValue()).filter(Objects::nonNull) + .collect(Collectors.joining(","))); + } + return params; }, SimpleEndpoint.emptyMap(), false, GetServiceAccountsResponse._DESERIALIZER); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetServiceAccountsResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetServiceAccountsResponse.java index 80f08243a4..efcb283769 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetServiceAccountsResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetServiceAccountsResponse.java @@ -19,7 +19,7 @@ package co.elastic.clients.elasticsearch.security; -import co.elastic.clients.elasticsearch.security.get_service_accounts.RoleDescriptorWrapper; +import co.elastic.clients.elasticsearch.security.get_service_accounts.ServiceAccountInfo; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -64,13 +64,13 @@ */ @JsonpDeserializable public class GetServiceAccountsResponse implements JsonpSerializable { - private final Map serviceAccoutns; + private final Map serviceAccounts; // --------------------------------------------------------------------------------------------- private GetServiceAccountsResponse(Builder builder) { - this.serviceAccoutns = ApiTypeHelper.unmodifiableRequired(builder.serviceAccoutns, this, "serviceAccoutns"); + this.serviceAccounts = ApiTypeHelper.unmodifiableRequired(builder.serviceAccounts, this, "serviceAccounts"); } @@ -81,15 +81,15 @@ public static GetServiceAccountsResponse of(Function serviceAccoutns() { - return this.serviceAccoutns; + public final Map serviceAccounts() { + return this.serviceAccounts; } /** - * Get an element of {@code serviceAccoutns}. + * Get an element of {@code serviceAccounts}. */ - public final @Nullable RoleDescriptorWrapper get(String key) { - return this.serviceAccoutns.get(key); + public final @Nullable ServiceAccountInfo get(String key) { + return this.serviceAccounts.get(key); } /** @@ -97,7 +97,7 @@ public final Map serviceAccoutns() { */ public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); - for (Map.Entry item0 : this.serviceAccoutns.entrySet()) { + for (Map.Entry item0 : this.serviceAccounts.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); @@ -120,45 +120,45 @@ public String toString() { public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { - private Map serviceAccoutns = new HashMap<>(); + private Map serviceAccounts = new HashMap<>(); /** * Required - Response value. *

- * Adds all entries of map to serviceAccoutns. + * Adds all entries of map to serviceAccounts. */ - public final Builder serviceAccoutns(Map map) { - this.serviceAccoutns = _mapPutAll(this.serviceAccoutns, map); + public final Builder serviceAccounts(Map map) { + this.serviceAccounts = _mapPutAll(this.serviceAccounts, map); return this; } /** * Required - Response value. *

- * Adds an entry to serviceAccoutns. + * Adds an entry to serviceAccounts. */ - public final Builder serviceAccoutns(String key, RoleDescriptorWrapper value) { - this.serviceAccoutns = _mapPut(this.serviceAccoutns, key, value); + public final Builder serviceAccounts(String key, ServiceAccountInfo value) { + this.serviceAccounts = _mapPut(this.serviceAccounts, key, value); return this; } /** * Required - Response value. *

- * Adds an entry to serviceAccoutns using a builder lambda. + * Adds an entry to serviceAccounts using a builder lambda. */ - public final Builder serviceAccoutns(String key, - Function> fn) { - return serviceAccoutns(key, fn.apply(new RoleDescriptorWrapper.Builder()).build()); + public final Builder serviceAccounts(String key, + Function> fn) { + return serviceAccounts(key, fn.apply(new ServiceAccountInfo.Builder()).build()); } @Override public Builder withJson(JsonParser parser, JsonpMapper mapper) { @SuppressWarnings("unchecked") - Map value = (Map) JsonpDeserializer - .stringMapDeserializer(RoleDescriptorWrapper._DESERIALIZER).deserialize(parser, mapper); - return this.serviceAccoutns(value); + Map value = (Map) JsonpDeserializer + .stringMapDeserializer(ServiceAccountInfo._DESERIALIZER).deserialize(parser, mapper); + return this.serviceAccounts(value); } @Override @@ -182,11 +182,11 @@ public GetServiceAccountsResponse build() { public static final JsonpDeserializer _DESERIALIZER = createGetServiceAccountsResponseDeserializer(); protected static JsonpDeserializer createGetServiceAccountsResponseDeserializer() { - JsonpDeserializer> valueDeserializer = JsonpDeserializer - .stringMapDeserializer(RoleDescriptorWrapper._DESERIALIZER); + JsonpDeserializer> valueDeserializer = JsonpDeserializer + .stringMapDeserializer(ServiceAccountInfo._DESERIALIZER); return JsonpDeserializer.of(valueDeserializer.acceptedEvents(), (parser, mapper, event) -> new Builder() - .serviceAccoutns(valueDeserializer.deserialize(parser, mapper, event)).build()); + .serviceAccounts(valueDeserializer.deserialize(parser, mapper, event)).build()); } } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetTokenRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetTokenRequest.java index ef7cf7f1c2..66dc11a0fb 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetTokenRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetTokenRequest.java @@ -100,6 +100,9 @@ public class GetTokenRequest extends RequestBase implements JsonpSerializable { @Nullable private final String scope; + @Nullable + private final String serviceAccountToken; + @Nullable private final String username; @@ -112,6 +115,7 @@ private GetTokenRequest(Builder builder) { this.password = builder.password; this.refreshToken = builder.refreshToken; this.scope = builder.scope; + this.serviceAccountToken = builder.serviceAccountToken; this.username = builder.username; } @@ -122,8 +126,8 @@ public static GetTokenRequest of(Functionpassword, - * _kerberos, client_credentials, and - * refresh_token. + * _kerberos, client_credentials, + * refresh_token, and _user_managed_service_account. *

* API name: {@code grant_type} */ @@ -180,6 +184,19 @@ public final String scope() { return this.scope; } + /** + * 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. This parameter is not valid with any other supported grant type. + *

+ * API name: {@code service_account_token} + */ + @Nullable + public final String serviceAccountToken() { + return this.serviceAccountToken; + } + /** * The username that identifies the user. If you specify the * password grant type, this parameter is required. This parameter @@ -226,6 +243,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("scope"); generator.write(this.scope); + } + if (this.serviceAccountToken != null) { + generator.writeKey("service_account_token"); + generator.write(this.serviceAccountToken); + } if (this.username != null) { generator.writeKey("username"); @@ -257,6 +279,9 @@ public static class Builder extends RequestBase.AbstractBuilder impleme @Nullable private String scope; + @Nullable + private String serviceAccountToken; + @Nullable private String username; @@ -268,13 +293,14 @@ private Builder(GetTokenRequest instance) { this.password = instance.password; this.refreshToken = instance.refreshToken; this.scope = instance.scope; + this.serviceAccountToken = instance.serviceAccountToken; this.username = instance.username; } /** * The type of grant. Supported grant types are: password, - * _kerberos, client_credentials, and - * refresh_token. + * _kerberos, client_credentials, + * refresh_token, and _user_managed_service_account. *

* API name: {@code grant_type} */ @@ -331,6 +357,19 @@ public final Builder scope(@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. This parameter is not valid with any other supported grant type. + *

+ * API name: {@code service_account_token} + */ + public final Builder serviceAccountToken(@Nullable String value) { + this.serviceAccountToken = value; + return this; + } + /** * The username that identifies the user. If you specify the * password grant type, this parameter is required. This parameter @@ -382,6 +421,7 @@ protected static void setupGetTokenRequestDeserializer(ObjectDeserializer dataSource; @@ -67,7 +68,7 @@ public class GlobalPrivilege implements JsonpSerializable { private GlobalPrivilege(Builder builder) { - this.application = ApiTypeHelper.requireNonNull(builder.application, this, "application"); + this.application = builder.application; this.dataSource = ApiTypeHelper.unmodifiable(builder.dataSource); } @@ -77,8 +78,9 @@ public static GlobalPrivilege of(Function implements ObjectBuilder { + @Nullable private ApplicationGlobalUserPrivileges application; @Nullable @@ -145,15 +150,15 @@ private Builder(GlobalPrivilege instance) { } /** - * Required - API name: {@code application} + * API name: {@code application} */ - public final Builder application(ApplicationGlobalUserPrivileges value) { + public final Builder application(@Nullable ApplicationGlobalUserPrivileges value) { this.application = value; return this; } /** - * Required - API name: {@code application} + * API name: {@code application} */ public final Builder application( Function> fn) { 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 new file mode 100644 index 0000000000..1355f0ce0a --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/PutUserManagedServiceAccountRequest.java @@ -0,0 +1,413 @@ +/* + * 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.Refresh; +import co.elastic.clients.elasticsearch._types.RequestBase; +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.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: security.put_user_managed_service_account.Request + +/** + * Create user-managed service accounts. + *

+ * Create a service account in a namespace of your own, or replace one that + * already exists. A replacement is not a partial update: every write applies + * the defaults, so an account that was disabled and is then written again + * without enabled comes back enabled. + *

+ * Creating an account whose name still has leftover service tokens is rejected. + * Delete those tokens first. + *

+ * NOTE: The elastic namespace is reserved for the built-in service + * accounts that ship with Elasticsearch. The + * manage_service_account privilege does not authorize this API. + * + * @see API + * specification + */ +@JsonpDeserializable +public class PutUserManagedServiceAccountRequest extends RequestBase implements JsonpSerializable { + @Nullable + private final Boolean enabled; + + private final String namespace; + + @Nullable + private final Refresh refresh; + + private final List roles; + + private final String service; + + // --------------------------------------------------------------------------------------------- + + private PutUserManagedServiceAccountRequest(Builder builder) { + + this.enabled = builder.enabled; + this.namespace = ApiTypeHelper.requireNonNull(builder.namespace, this, "namespace"); + this.refresh = builder.refresh; + this.roles = ApiTypeHelper.unmodifiableRequired(builder.roles, this, "roles"); + this.service = ApiTypeHelper.requireNonNull(builder.service, this, "service"); + + } + + public static PutUserManagedServiceAccountRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Whether the account can authenticate. Tokens can still be created for a + * disabled account; they just cannot be used until the account is enabled. + *

+ * API name: {@code enabled} + */ + @Nullable + public final Boolean enabled() { + return this.enabled; + } + + /** + * Required - The namespace, which is a top-level grouping of service accounts. + * It must start with a letter or digit and can contain only letters, digits, + * hyphens, and underscores, up to a maximum of 128 characters. It cannot be + * elastic, which is reserved for built-in service accounts. + *

+ * API name: {@code namespace} + */ + public final String namespace() { + return this.namespace; + } + + /** + * If wait_for (the default) then wait for a refresh to make this + * operation visible to search, if true then refresh the affected + * shards to make this operation visible to search, if false then + * do nothing with refreshes. + *

+ * API name: {@code refresh} + */ + @Nullable + public final Refresh refresh() { + return this.refresh; + } + + /** + * Required - The names of the roles to grant to the service account, up to a + * maximum of 1000. The roles are resolved when the account authenticates, so + * they do not have to exist yet. + *

+ * API name: {@code roles} + */ + public final List roles() { + return this.roles; + } + + /** + * Required - The service name. It must start with a letter or digit and can + * contain only letters, digits, hyphens, and underscores, up to a maximum of + * 128 characters. + *

+ * API name: {@code service} + */ + public final String service() { + return this.service; + } + + /** + * 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.enabled != null) { + generator.writeKey("enabled"); + generator.write(this.enabled); + + } + if (ApiTypeHelper.isDefined(this.roles)) { + generator.writeKey("roles"); + generator.writeStartArray(); + for (String item0 : this.roles) { + generator.write(item0); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link PutUserManagedServiceAccountRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private Boolean enabled; + + private String namespace; + + @Nullable + private Refresh refresh; + + private List roles; + + private String service; + + public Builder() { + } + private Builder(PutUserManagedServiceAccountRequest instance) { + this.enabled = instance.enabled; + this.namespace = instance.namespace; + this.refresh = instance.refresh; + this.roles = instance.roles; + this.service = instance.service; + + } + /** + * Whether the account can authenticate. Tokens can still be created for a + * disabled account; they just cannot be used until the account is enabled. + *

+ * API name: {@code enabled} + */ + public final Builder enabled(@Nullable Boolean value) { + this.enabled = value; + return this; + } + + /** + * Required - The namespace, which is a top-level grouping of service accounts. + * It must start with a letter or digit and can contain only letters, digits, + * hyphens, and underscores, up to a maximum of 128 characters. It cannot be + * elastic, which is reserved for built-in service accounts. + *

+ * API name: {@code namespace} + */ + public final Builder namespace(String value) { + this.namespace = value; + return this; + } + + /** + * If wait_for (the default) then wait for a refresh to make this + * operation visible to search, if true then refresh the affected + * shards to make this operation visible to search, if false then + * do nothing with refreshes. + *

+ * API name: {@code refresh} + */ + public final Builder refresh(@Nullable Refresh value) { + this.refresh = value; + return this; + } + + /** + * Required - The names of the roles to grant to the service account, up to a + * maximum of 1000. The roles are resolved when the account authenticates, so + * they do not have to exist yet. + *

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

+ * Adds all elements of list to roles. + */ + public final Builder roles(List list) { + this.roles = _listAddAll(this.roles, list); + return this; + } + + /** + * Required - The names of the roles to grant to the service account, up to a + * maximum of 1000. The roles are resolved when the account authenticates, so + * they do not have to exist yet. + *

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

+ * Adds one or more values to roles. + */ + public final Builder roles(String value, String... values) { + this.roles = _listAdd(this.roles, value, values); + return this; + } + + /** + * Required - The service name. It must start with a letter or digit and can + * contain only letters, digits, hyphens, and underscores, up to a maximum of + * 128 characters. + *

+ * API name: {@code service} + */ + public final Builder service(String value) { + this.service = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link PutUserManagedServiceAccountRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public PutUserManagedServiceAccountRequest build() { + _checkSingleUse(); + + return new PutUserManagedServiceAccountRequest(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link PutUserManagedServiceAccountRequest} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + PutUserManagedServiceAccountRequest::setupPutUserManagedServiceAccountRequestDeserializer); + + protected static void setupPutUserManagedServiceAccountRequestDeserializer( + ObjectDeserializer op) { + + op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "roles"); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code security.put_user_managed_service_account}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/security.put_user_managed_service_account", + + // Request method + request -> { + return "PUT"; + + }, + + // Request path + request -> { + final int _service = 1 << 0; + final int _namespace = 1 << 1; + + int propsSet = 0; + + propsSet |= _service; + propsSet |= _namespace; + + if (propsSet == (_namespace | _service)) { + StringBuilder buf = new StringBuilder(); + buf.append("/_security"); + buf.append("/service"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.namespace, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.service, buf); + return buf.toString(); + } + throw SimpleEndpoint.noPathTemplateFound("path"); + + }, + + // Path parameters + request -> { + Map params = new HashMap<>(); + final int _service = 1 << 0; + final int _namespace = 1 << 1; + + int propsSet = 0; + + propsSet |= _service; + propsSet |= _namespace; + + if (propsSet == (_namespace | _service)) { + params.put("namespace", request.namespace); + params.put("service", request.service); + } + return params; + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.refresh != null) { + params.put("refresh", request.refresh.jsonValue()); + } + return params; + + }, SimpleEndpoint.emptyMap(), true, PutUserManagedServiceAccountResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/PutUserManagedServiceAccountResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/PutUserManagedServiceAccountResponse.java new file mode 100644 index 0000000000..7aa5338a05 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/PutUserManagedServiceAccountResponse.java @@ -0,0 +1,166 @@ +/* + * 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.Boolean; +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: security.put_user_managed_service_account.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class PutUserManagedServiceAccountResponse implements JsonpSerializable { + private final boolean created; + + // --------------------------------------------------------------------------------------------- + + private PutUserManagedServiceAccountResponse(Builder builder) { + + this.created = ApiTypeHelper.requireNonNull(builder.created, this, "created", false); + + } + + public static PutUserManagedServiceAccountResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - A successful call returns a JSON structure that shows whether the + * service account has been created or updated. When an existing service account + * is replaced, created is set to false. + *

+ * API name: {@code created} + */ + public final boolean created() { + return this.created; + } + + /** + * 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("created"); + generator.write(this.created); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link PutUserManagedServiceAccountResponse}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private Boolean created; + + /** + * Required - A successful call returns a JSON structure that shows whether the + * service account has been created or updated. When an existing service account + * is replaced, created is set to false. + *

+ * API name: {@code created} + */ + public final Builder created(boolean value) { + this.created = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link PutUserManagedServiceAccountResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public PutUserManagedServiceAccountResponse build() { + _checkSingleUse(); + + return new PutUserManagedServiceAccountResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link PutUserManagedServiceAccountResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + PutUserManagedServiceAccountResponse::setupPutUserManagedServiceAccountResponseDeserializer); + + protected static void setupPutUserManagedServiceAccountResponseDeserializer( + ObjectDeserializer op) { + + op.add(Builder::created, JsonpDeserializer.booleanDeserializer(), "created"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleDescriptorRead.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleDescriptorRead.java index bcf46304c6..4b358d7e58 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleDescriptorRead.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleDescriptorRead.java @@ -738,8 +738,7 @@ protected static void setupRoleDescriptorReadDeserializer(ObjectDeserializerAPI + * "../../doc-files/api-spec.html#security.get_service_accounts.BuiltInServiceAccount">API * specification */ @JsonpDeserializable -public class RoleDescriptorWrapper implements JsonpSerializable { +public class BuiltInServiceAccount implements ServiceAccountInfoVariant, JsonpSerializable { private final RoleDescriptorRead roleDescriptor; // --------------------------------------------------------------------------------------------- - private RoleDescriptorWrapper(Builder builder) { + private BuiltInServiceAccount(Builder builder) { this.roleDescriptor = ApiTypeHelper.requireNonNull(builder.roleDescriptor, this, "roleDescriptor"); } - public static RoleDescriptorWrapper of(Function> fn) { + public static BuiltInServiceAccount of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Required - API name: {@code role_descriptor} + * ServiceAccountInfo variant kind. + */ + @Override + public ServiceAccountInfo.Kind _serviceAccountInfoKind() { + return ServiceAccountInfo.Kind.BuiltIn; + } + + /** + * Required - The role descriptor declared for the account in the Elasticsearch + * distribution. + *

+ * API name: {@code role_descriptor} */ public final RoleDescriptorRead roleDescriptor() { return this.roleDescriptor; @@ -92,6 +103,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.write("type", "built_in"); + generator.writeKey("role_descriptor"); this.roleDescriptor.serialize(generator, mapper); @@ -105,22 +118,25 @@ public String toString() { // --------------------------------------------------------------------------------------------- /** - * Builder for {@link RoleDescriptorWrapper}. + * Builder for {@link BuiltInServiceAccount}. */ public static class Builder extends WithJsonObjectBuilderBase implements - ObjectBuilder { + ObjectBuilder { private RoleDescriptorRead roleDescriptor; public Builder() { } - private Builder(RoleDescriptorWrapper instance) { + private Builder(BuiltInServiceAccount instance) { this.roleDescriptor = instance.roleDescriptor; } /** - * Required - API name: {@code role_descriptor} + * Required - The role descriptor declared for the account in the Elasticsearch + * distribution. + *

+ * API name: {@code role_descriptor} */ public final Builder roleDescriptor(RoleDescriptorRead value) { this.roleDescriptor = value; @@ -128,7 +144,10 @@ public final Builder roleDescriptor(RoleDescriptorRead value) { } /** - * Required - API name: {@code role_descriptor} + * Required - The role descriptor declared for the account in the Elasticsearch + * distribution. + *

+ * API name: {@code role_descriptor} */ public final Builder roleDescriptor( Function> fn) { @@ -141,15 +160,15 @@ protected Builder self() { } /** - * Builds a {@link RoleDescriptorWrapper}. + * Builds a {@link BuiltInServiceAccount}. * * @throws NullPointerException * if some of the required fields are null. */ - public RoleDescriptorWrapper build() { + public BuiltInServiceAccount build() { _checkSingleUse(); - return new RoleDescriptorWrapper(this); + return new BuiltInServiceAccount(this); } } @@ -162,15 +181,16 @@ public Builder rebuild() { // --------------------------------------------------------------------------------------------- /** - * Json deserializer for {@link RoleDescriptorWrapper} + * Json deserializer for {@link BuiltInServiceAccount} */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, RoleDescriptorWrapper::setupRoleDescriptorWrapperDeserializer); + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, BuiltInServiceAccount::setupBuiltInServiceAccountDeserializer); - protected static void setupRoleDescriptorWrapperDeserializer(ObjectDeserializer op) { + protected static void setupBuiltInServiceAccountDeserializer(ObjectDeserializer op) { op.add(Builder::roleDescriptor, RoleDescriptorRead._DESERIALIZER, "role_descriptor"); + op.ignore("type"); } } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountInfo.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountInfo.java new file mode 100644 index 0000000000..0736e64b55 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountInfo.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.security.get_service_accounts; + +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: security.get_service_accounts.ServiceAccountInfo + +/** + * The two kinds of service account describe their privileges differently. A + * built-in account includes its role descriptor. A user-managed account + * includes its role names and whether it is enabled. + * + * @see API + * specification + */ +@JsonpDeserializable +public class ServiceAccountInfo + implements + TaggedUnion, + JsonpSerializable { + + /** + * {@link ServiceAccountInfo} variant kinds. + * + * @see API + * specification + */ + + public enum Kind implements JsonEnum { + BuiltIn("built_in"), + + UserManaged("user_managed"), + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final ServiceAccountInfoVariant _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final ServiceAccountInfoVariant _get() { + return _value; + } + + public ServiceAccountInfo(ServiceAccountInfoVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._serviceAccountInfoKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + + } + + private ServiceAccountInfo(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static ServiceAccountInfo of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code built_in}? + */ + public boolean isBuiltIn() { + return _kind == Kind.BuiltIn; + } + + /** + * Get the {@code built_in} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code built_in} kind. + */ + public BuiltInServiceAccount builtIn() { + return TaggedUnionUtils.get(this, Kind.BuiltIn); + } + + /** + * Is this variant instance of kind {@code user_managed}? + */ + public boolean isUserManaged() { + return _kind == Kind.UserManaged; + } + + /** + * Get the {@code user_managed} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code user_managed} kind. + */ + public UserManagedServiceAccount userManaged() { + return TaggedUnionUtils.get(this, Kind.UserManaged); + } + + @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 ServiceAccountInfoVariant _value; + + @Override + protected Builder self() { + return this; + } + public ObjectBuilder builtIn(BuiltInServiceAccount v) { + this._kind = Kind.BuiltIn; + this._value = v; + return this; + } + + public ObjectBuilder builtIn( + Function> fn) { + return this.builtIn(fn.apply(new BuiltInServiceAccount.Builder()).build()); + } + + public ObjectBuilder userManaged(UserManagedServiceAccount v) { + this._kind = Kind.UserManaged; + this._value = v; + return this; + } + + public ObjectBuilder userManaged( + Function> fn) { + return this.userManaged(fn.apply(new UserManagedServiceAccount.Builder()).build()); + } + + public ServiceAccountInfo build() { + _checkSingleUse(); + return new ServiceAccountInfo(this); + } + + } + + protected static void setupServiceAccountInfoDeserializer(ObjectDeserializer op) { + + op.add(Builder::builtIn, BuiltInServiceAccount._DESERIALIZER, "built_in"); + op.add(Builder::userManaged, UserManagedServiceAccount._DESERIALIZER, "user_managed"); + + op.setTypeProperty("type", null); + + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ServiceAccountInfo::setupServiceAccountInfoDeserializer, Builder::build); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountInfoBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountInfoBuilders.java new file mode 100644 index 0000000000..8b19a5d582 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountInfoBuilders.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.security.get_service_accounts; + +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 ServiceAccountInfo} variants. + */ +public class ServiceAccountInfoBuilders { + private ServiceAccountInfoBuilders() { + } + + /** + * Creates a builder for the {@link BuiltInServiceAccount built_in} + * {@code ServiceAccountInfo} variant. + */ + public static BuiltInServiceAccount.Builder builtIn() { + return new BuiltInServiceAccount.Builder(); + } + + /** + * Creates a ServiceAccountInfo of the {@link BuiltInServiceAccount built_in} + * {@code ServiceAccountInfo} variant. + */ + public static ServiceAccountInfo builtIn( + Function> fn) { + ServiceAccountInfo.Builder builder = new ServiceAccountInfo.Builder(); + builder.builtIn(fn.apply(new BuiltInServiceAccount.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link UserManagedServiceAccount user_managed} + * {@code ServiceAccountInfo} variant. + */ + public static UserManagedServiceAccount.Builder userManaged() { + return new UserManagedServiceAccount.Builder(); + } + + /** + * Creates a ServiceAccountInfo of the {@link UserManagedServiceAccount + * user_managed} {@code ServiceAccountInfo} variant. + */ + public static ServiceAccountInfo userManaged( + Function> fn) { + ServiceAccountInfo.Builder builder = new ServiceAccountInfo.Builder(); + builder.userManaged(fn.apply(new UserManagedServiceAccount.Builder()).build()); + return builder.build(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountInfoVariant.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountInfoVariant.java new file mode 100644 index 0000000000..f8d6a15e63 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountInfoVariant.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.security.get_service_accounts; + +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 ServiceAccountInfo} variants. + */ +public interface ServiceAccountInfoVariant extends JsonpSerializable { + + ServiceAccountInfo.Kind _serviceAccountInfoKind(); + + default ServiceAccountInfo _toServiceAccountInfo() { + return new ServiceAccountInfo(this); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountType.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountType.java new file mode 100644 index 0000000000..3cc17257a2 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/ServiceAccountType.java @@ -0,0 +1,74 @@ +/* + * 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.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 ServiceAccountType implements JsonEnum { + /** + * An account that ships with Elasticsearch, in the reserved + * elastic namespace. + */ + BuiltIn("built_in"), + + /** + * An account created with the put user-managed service account API. + */ + UserManaged("user_managed"), + + ; + + private final String jsonValue; + + ServiceAccountType(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + ServiceAccountType.values()); +} 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 new file mode 100644 index 0000000000..6feaad433f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_service_accounts/UserManagedServiceAccount.java @@ -0,0 +1,239 @@ +/* + * 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.Boolean; +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.get_service_accounts.UserManagedServiceAccount + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class UserManagedServiceAccount implements ServiceAccountInfoVariant, JsonpSerializable { + private final List roles; + + private final boolean enabled; + + // --------------------------------------------------------------------------------------------- + + private UserManagedServiceAccount(Builder builder) { + + this.roles = ApiTypeHelper.unmodifiableRequired(builder.roles, this, "roles"); + this.enabled = ApiTypeHelper.requireNonNull(builder.enabled, this, "enabled", false); + + } + + public static UserManagedServiceAccount of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * ServiceAccountInfo variant kind. + */ + @Override + public ServiceAccountInfo.Kind _serviceAccountInfoKind() { + return ServiceAccountInfo.Kind.UserManaged; + } + + /** + * 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. + *

+ * API name: {@code roles} + */ + public final List roles() { + return this.roles; + } + + /** + * Required - Whether the account can authenticate. + *

+ * API name: {@code enabled} + */ + public final boolean enabled() { + return this.enabled; + } + + /** + * 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", "user_managed"); + + if (ApiTypeHelper.isDefined(this.roles)) { + generator.writeKey("roles"); + generator.writeStartArray(); + for (String item0 : this.roles) { + generator.write(item0); + + } + generator.writeEnd(); + + } + generator.writeKey("enabled"); + generator.write(this.enabled); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link UserManagedServiceAccount}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private List roles; + + private Boolean enabled; + + public Builder() { + } + private Builder(UserManagedServiceAccount instance) { + this.roles = instance.roles; + this.enabled = instance.enabled; + + } + /** + * 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. + *

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

+ * Adds all elements of list to roles. + */ + public final Builder roles(List list) { + this.roles = _listAddAll(this.roles, list); + return this; + } + + /** + * 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. + *

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

+ * Adds one or more values to roles. + */ + public final Builder roles(String value, String... values) { + this.roles = _listAdd(this.roles, value, values); + return this; + } + + /** + * Required - Whether the account can authenticate. + *

+ * API name: {@code enabled} + */ + public final Builder enabled(boolean value) { + this.enabled = value; + return this; + } + + @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); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link UserManagedServiceAccount} + */ + 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"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_token/AccessTokenGrantType.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_token/AccessTokenGrantType.java index d247d1e66a..2eefa808da 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_token/AccessTokenGrantType.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_token/AccessTokenGrantType.java @@ -81,6 +81,21 @@ public enum AccessTokenGrantType implements JsonEnum { */ RefreshToken("refresh_token"), + /** + * This grant type is supported internally and exchanges a user-managed service + * account token for an access token that represents that service account. The + * request must be made by an authenticated caller with the + * manage_token cluster privilege, on behalf of the service account + * whose token is passed in the service_account_token parameter. + * The service account token is authenticated on every exchange, so a disabled + * account or an invalidated token is rejected. Tokens that belong to built-in + * (elastic/*) service accounts are rejected. It generates only + * access tokens that cannot be refreshed. The + * _user_managed_service_account grant type may change from version + * to version. + */ + UserManagedServiceAccount("_user_managed_service_account"), + ; private final String jsonValue;