diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MappingCharFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MappingCharFilter.java index 02d7f2304..ea69ce323 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MappingCharFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MappingCharFilter.java @@ -57,7 +57,7 @@ public class MappingCharFilter extends CharFilterBase implements CharFilterDefin private MappingCharFilter(Builder builder) { super(builder); - this.mappings = ApiTypeHelper.unmodifiableRequired(builder.mappings, this, "mappings"); + this.mappings = ApiTypeHelper.unmodifiable(builder.mappings); this.mappingsPath = builder.mappingsPath; } @@ -75,7 +75,7 @@ public CharFilterDefinition.Kind _charFilterDefinitionKind() { } /** - * Required - API name: {@code mappings} + * API name: {@code mappings} */ public final List mappings() { return this.mappings; @@ -120,13 +120,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends CharFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private List mappings; @Nullable private String mappingsPath; /** - * Required - API name: {@code mappings} + * API name: {@code mappings} *

* Adds all elements of list to mappings. */ @@ -136,7 +137,7 @@ public final Builder mappings(List list) { } /** - * Required - API name: {@code mappings} + * API name: {@code mappings} *

* Adds one or more values to mappings. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PhraseSuggest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PhraseSuggest.java index 8259e8ed0..ff242d49c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PhraseSuggest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PhraseSuggest.java @@ -31,6 +31,7 @@ import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; +import java.util.List; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -45,14 +46,14 @@ */ @JsonpDeserializable public class PhraseSuggest extends SuggestBase implements SuggestionVariant { - private final PhraseSuggestOption options; + private final List options; // --------------------------------------------------------------------------------------------- private PhraseSuggest(Builder builder) { super(builder); - this.options = ApiTypeHelper.requireNonNull(builder.options, this, "options"); + this.options = ApiTypeHelper.unmodifiableRequired(builder.options, this, "options"); } @@ -71,15 +72,23 @@ public Suggestion.Kind _suggestionKind() { /** * Required - API name: {@code options} */ - public final PhraseSuggestOption options() { + public final List options() { return this.options; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { super.serializeInternal(generator, mapper); - generator.writeKey("options"); - this.options.serialize(generator, mapper); + if (ApiTypeHelper.isDefined(this.options)) { + generator.writeKey("options"); + generator.writeStartArray(); + for (PhraseSuggestOption item0 : this.options) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } } @@ -90,21 +99,35 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { */ public static class Builder extends SuggestBase.AbstractBuilder implements ObjectBuilder { - private PhraseSuggestOption options; + private List options; + + /** + * Required - API name: {@code options} + *

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

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

+ * Adds a value to options using a builder lambda. */ public final Builder options(Function> fn) { - return this.options(fn.apply(new PhraseSuggestOption.Builder()).build()); + return options(fn.apply(new PhraseSuggestOption.Builder()).build()); } @Override @@ -135,7 +158,7 @@ public PhraseSuggest build() { protected static void setupPhraseSuggestDeserializer(ObjectDeserializer op) { SuggestBase.setupSuggestBaseDeserializer(op); - op.add(Builder::options, PhraseSuggestOption._DESERIALIZER, "options"); + op.add(Builder::options, JsonpDeserializer.arrayDeserializer(PhraseSuggestOption._DESERIALIZER), "options"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/TermSuggest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/TermSuggest.java index c397b4683..c4811738f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/TermSuggest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/TermSuggest.java @@ -31,6 +31,7 @@ import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; +import java.util.List; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -45,14 +46,14 @@ */ @JsonpDeserializable public class TermSuggest extends SuggestBase implements SuggestionVariant { - private final TermSuggestOption options; + private final List options; // --------------------------------------------------------------------------------------------- private TermSuggest(Builder builder) { super(builder); - this.options = ApiTypeHelper.requireNonNull(builder.options, this, "options"); + this.options = ApiTypeHelper.unmodifiableRequired(builder.options, this, "options"); } @@ -71,15 +72,23 @@ public Suggestion.Kind _suggestionKind() { /** * Required - API name: {@code options} */ - public final TermSuggestOption options() { + public final List options() { return this.options; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { super.serializeInternal(generator, mapper); - generator.writeKey("options"); - this.options.serialize(generator, mapper); + if (ApiTypeHelper.isDefined(this.options)) { + generator.writeKey("options"); + generator.writeStartArray(); + for (TermSuggestOption item0 : this.options) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } } @@ -90,21 +99,35 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { */ public static class Builder extends SuggestBase.AbstractBuilder implements ObjectBuilder { - private TermSuggestOption options; + private List options; + + /** + * Required - API name: {@code options} + *

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

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

+ * Adds a value to options using a builder lambda. */ public final Builder options(Function> fn) { - return this.options(fn.apply(new TermSuggestOption.Builder()).build()); + return options(fn.apply(new TermSuggestOption.Builder()).build()); } @Override @@ -135,7 +158,7 @@ public TermSuggest build() { protected static void setupTermSuggestDeserializer(ObjectDeserializer op) { SuggestBase.setupSuggestBaseDeserializer(op); - op.add(Builder::options, TermSuggestOption._DESERIALIZER, "options"); + op.add(Builder::options, JsonpDeserializer.arrayDeserializer(TermSuggestOption._DESERIALIZER), "options"); } 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 a84d659b0..90110f36e 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 @@ -133,17 +133,17 @@ '_global.search._types.AggregationProfileDelegateDebugFilter': '_global/search/_types/profile.ts#L69-L73', '_global.search._types.BoundaryScanner': '_global/search/_types/highlighting.ts#L26-L30', '_global.search._types.Collector': '_global/search/_types/profile.ts#L84-L89', -'_global.search._types.CompletionContext': '_global/search/_types/suggester.ts#L150-L157', -'_global.search._types.CompletionSuggest': '_global/search/_types/suggester.ts#L48-L53', -'_global.search._types.CompletionSuggestOption': '_global/search/_types/suggester.ts#L71-L82', -'_global.search._types.CompletionSuggester': '_global/search/_types/suggester.ts#L125-L131', -'_global.search._types.Context': '_global/search/_types/suggester.ts#L143-L148', -'_global.search._types.DirectGenerator': '_global/search/_types/suggester.ts#L161-L173', +'_global.search._types.CompletionContext': '_global/search/_types/suggester.ts#L152-L159', +'_global.search._types.CompletionSuggest': '_global/search/_types/suggester.ts#L48-L55', +'_global.search._types.CompletionSuggestOption': '_global/search/_types/suggester.ts#L73-L84', +'_global.search._types.CompletionSuggester': '_global/search/_types/suggester.ts#L127-L133', +'_global.search._types.Context': '_global/search/_types/suggester.ts#L145-L150', +'_global.search._types.DirectGenerator': '_global/search/_types/suggester.ts#L163-L175', '_global.search._types.FetchProfile': '_global/search/_types/profile.ts#L137-L144', '_global.search._types.FetchProfileBreakdown': '_global/search/_types/profile.ts#L146-L153', '_global.search._types.FetchProfileDebug': '_global/search/_types/profile.ts#L155-L158', '_global.search._types.FieldCollapse': '_global/search/_types/FieldCollapse.ts#L24-L29', -'_global.search._types.FieldSuggester': '_global/search/_types/suggester.ts#L101-L115', +'_global.search._types.FieldSuggester': '_global/search/_types/suggester.ts#L103-L117', '_global.search._types.Highlight': '_global/search/_types/highlighting.ts#L56-L59', '_global.search._types.HighlightBase': '_global/search/_types/highlighting.ts#L32-L54', '_global.search._types.HighlightField': '_global/search/_types/highlighting.ts#L87-L90', @@ -156,15 +156,15 @@ '_global.search._types.HitsMetadata': '_global/search/_types/hits.ts#L62-L68', '_global.search._types.InnerHits': '_global/search/_types/hits.ts#L102-L120', '_global.search._types.InnerHitsResult': '_global/search/_types/hits.ts#L80-L82', -'_global.search._types.LaplaceSmoothingModel': '_global/search/_types/suggester.ts#L207-L209', -'_global.search._types.LinearInterpolationSmoothingModel': '_global/search/_types/suggester.ts#L211-L215', +'_global.search._types.LaplaceSmoothingModel': '_global/search/_types/suggester.ts#L209-L211', +'_global.search._types.LinearInterpolationSmoothingModel': '_global/search/_types/suggester.ts#L213-L217', '_global.search._types.NestedIdentity': '_global/search/_types/hits.ts#L84-L88', -'_global.search._types.PhraseSuggest': '_global/search/_types/suggester.ts#L55-L60', -'_global.search._types.PhraseSuggestCollate': '_global/search/_types/suggester.ts#L175-L179', -'_global.search._types.PhraseSuggestCollateQuery': '_global/search/_types/suggester.ts#L181-L184', -'_global.search._types.PhraseSuggestHighlight': '_global/search/_types/suggester.ts#L202-L205', -'_global.search._types.PhraseSuggestOption': '_global/search/_types/suggester.ts#L84-L88', -'_global.search._types.PhraseSuggester': '_global/search/_types/suggester.ts#L186-L200', +'_global.search._types.PhraseSuggest': '_global/search/_types/suggester.ts#L57-L62', +'_global.search._types.PhraseSuggestCollate': '_global/search/_types/suggester.ts#L177-L181', +'_global.search._types.PhraseSuggestCollateQuery': '_global/search/_types/suggester.ts#L183-L186', +'_global.search._types.PhraseSuggestHighlight': '_global/search/_types/suggester.ts#L204-L207', +'_global.search._types.PhraseSuggestOption': '_global/search/_types/suggester.ts#L86-L90', +'_global.search._types.PhraseSuggester': '_global/search/_types/suggester.ts#L188-L202', '_global.search._types.PointInTimeReference': '_global/search/_types/PointInTimeReference.ts#L23-L26', '_global.search._types.Profile': '_global/search/_types/profile.ts#L91-L93', '_global.search._types.QueryBreakdown': '_global/search/_types/profile.ts#L95-L114', @@ -174,21 +174,21 @@ '_global.search._types.ScoreMode': '_global/search/_types/rescoring.ts#L36-L42', '_global.search._types.SearchProfile': '_global/search/_types/profile.ts#L124-L128', '_global.search._types.ShardProfile': '_global/search/_types/profile.ts#L130-L135', -'_global.search._types.SmoothingModelContainer': '_global/search/_types/suggester.ts#L219-L226', +'_global.search._types.SmoothingModelContainer': '_global/search/_types/suggester.ts#L221-L228', '_global.search._types.SourceConfig': '_global/search/_types/SourceFilter.ts#L33-L37', '_global.search._types.SourceConfigParam': '_global/search/_types/SourceFilter.ts#L39-L45', '_global.search._types.SourceFilter': '_global/search/_types/SourceFilter.ts#L23-L31', -'_global.search._types.StringDistance': '_global/search/_types/suggester.ts#L234-L240', -'_global.search._types.StupidBackoffSmoothingModel': '_global/search/_types/suggester.ts#L228-L230', +'_global.search._types.StringDistance': '_global/search/_types/suggester.ts#L236-L242', +'_global.search._types.StupidBackoffSmoothingModel': '_global/search/_types/suggester.ts#L230-L232', '_global.search._types.Suggest': '_global/search/_types/suggester.ts#L34-L40', '_global.search._types.SuggestBase': '_global/search/_types/suggester.ts#L42-L46', -'_global.search._types.SuggestFuzziness': '_global/search/_types/suggester.ts#L133-L139', -'_global.search._types.SuggestSort': '_global/search/_types/suggester.ts#L242-L245', -'_global.search._types.Suggester': '_global/search/_types/suggester.ts#L96-L99', -'_global.search._types.SuggesterBase': '_global/search/_types/suggester.ts#L117-L121', -'_global.search._types.TermSuggest': '_global/search/_types/suggester.ts#L62-L67', -'_global.search._types.TermSuggestOption': '_global/search/_types/suggester.ts#L90-L94', -'_global.search._types.TermSuggester': '_global/search/_types/suggester.ts#L247-L260', +'_global.search._types.SuggestFuzziness': '_global/search/_types/suggester.ts#L135-L141', +'_global.search._types.SuggestSort': '_global/search/_types/suggester.ts#L244-L247', +'_global.search._types.Suggester': '_global/search/_types/suggester.ts#L98-L101', +'_global.search._types.SuggesterBase': '_global/search/_types/suggester.ts#L119-L123', +'_global.search._types.TermSuggest': '_global/search/_types/suggester.ts#L64-L69', +'_global.search._types.TermSuggestOption': '_global/search/_types/suggester.ts#L92-L96', +'_global.search._types.TermSuggester': '_global/search/_types/suggester.ts#L249-L262', '_global.search._types.TotalHits': '_global/search/_types/hits.ts#L90-L93', '_global.search._types.TotalHitsRelation': '_global/search/_types/hits.ts#L95-L100', '_global.search._types.TrackHits': '_global/search/_types/hits.ts#L122-L130', @@ -2511,10 +2511,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/1b56d7e58f5c59f05d1641c6d6a8117c5e01d741/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/4086ea1303849795e8171557d62f1239507b27c7/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/ml/ApiKeyAuthorization.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/ApiKeyAuthorization.java new file mode 100644 index 000000000..1affe4217 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/ApiKeyAuthorization.java @@ -0,0 +1,176 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package co.elastic.clients.elasticsearch.ml; + +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; + +// typedef: ml._types.ApiKeyAuthorization + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ApiKeyAuthorization implements JsonpSerializable { + private final String id; + + private final String name; + + // --------------------------------------------------------------------------------------------- + + private ApiKeyAuthorization(Builder builder) { + + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); + + } + + public static ApiKeyAuthorization of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The identifier for the API key. + *

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

+ * API name: {@code name} + */ + public final String name() { + return this.name; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("id"); + generator.write(this.id); + + generator.writeKey("name"); + generator.write(this.name); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ApiKeyAuthorization}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String id; + + private String name; + + /** + * Required - The identifier for the API key. + *

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

+ * API name: {@code name} + */ + public final Builder name(String value) { + this.name = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ApiKeyAuthorization}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ApiKeyAuthorization build() { + _checkSingleUse(); + + return new ApiKeyAuthorization(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ApiKeyAuthorization} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ApiKeyAuthorization::setupApiKeyAuthorizationDeserializer); + + protected static void setupApiKeyAuthorizationDeserializer(ObjectDeserializer op) { + + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DatafeedAuthorization.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DatafeedAuthorization.java new file mode 100644 index 000000000..318d94d10 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DatafeedAuthorization.java @@ -0,0 +1,255 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package co.elastic.clients.elasticsearch.ml; + +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; + +// typedef: ml._types.DatafeedAuthorization + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DatafeedAuthorization implements JsonpSerializable { + @Nullable + private final ApiKeyAuthorization apiKey; + + private final List roles; + + @Nullable + private final String serviceAccount; + + // --------------------------------------------------------------------------------------------- + + private DatafeedAuthorization(Builder builder) { + + this.apiKey = builder.apiKey; + this.roles = ApiTypeHelper.unmodifiable(builder.roles); + this.serviceAccount = builder.serviceAccount; + + } + + public static DatafeedAuthorization of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * If an API key was used for the most recent update to the datafeed, its name + * and identifier are listed in the response. + *

+ * API name: {@code api_key} + */ + @Nullable + public final ApiKeyAuthorization apiKey() { + return this.apiKey; + } + + /** + * If a user ID was used for the most recent update to the datafeed, its roles + * at the time of the update are listed in the response. + *

+ * API name: {@code roles} + */ + public final List roles() { + return this.roles; + } + + /** + * If a service account was used for the most recent update to the datafeed, the + * account name is listed in the response. + *

+ * API name: {@code service_account} + */ + @Nullable + public final String serviceAccount() { + return this.serviceAccount; + } + + /** + * 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.apiKey != null) { + generator.writeKey("api_key"); + this.apiKey.serialize(generator, mapper); + + } + if (ApiTypeHelper.isDefined(this.roles)) { + generator.writeKey("roles"); + generator.writeStartArray(); + for (String item0 : this.roles) { + generator.write(item0); + + } + generator.writeEnd(); + + } + if (this.serviceAccount != null) { + generator.writeKey("service_account"); + generator.write(this.serviceAccount); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DatafeedAuthorization}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private ApiKeyAuthorization apiKey; + + @Nullable + private List roles; + + @Nullable + private String serviceAccount; + + /** + * If an API key was used for the most recent update to the datafeed, its name + * and identifier are listed in the response. + *

+ * API name: {@code api_key} + */ + public final Builder apiKey(@Nullable ApiKeyAuthorization value) { + this.apiKey = value; + return this; + } + + /** + * If an API key was used for the most recent update to the datafeed, its name + * and identifier are listed in the response. + *

+ * API name: {@code api_key} + */ + public final Builder apiKey(Function> fn) { + return this.apiKey(fn.apply(new ApiKeyAuthorization.Builder()).build()); + } + + /** + * If a user ID was used for the most recent update to the datafeed, its roles + * at the time of the update are listed in the response. + *

+ * 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; + } + + /** + * If a user ID was used for the most recent update to the datafeed, its roles + * at the time of the update are listed in the response. + *

+ * 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; + } + + /** + * If a service account was used for the most recent update to the datafeed, the + * account name is listed in the response. + *

+ * API name: {@code service_account} + */ + public final Builder serviceAccount(@Nullable String value) { + this.serviceAccount = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DatafeedAuthorization}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DatafeedAuthorization build() { + _checkSingleUse(); + + return new DatafeedAuthorization(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DatafeedAuthorization} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DatafeedAuthorization::setupDatafeedAuthorizationDeserializer); + + protected static void setupDatafeedAuthorizationDeserializer(ObjectDeserializer op) { + + op.add(Builder::apiKey, ApiKeyAuthorization._DESERIALIZER, "api_key"); + op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "roles"); + op.add(Builder::serviceAccount, JsonpDeserializer.stringDeserializer(), "service_account"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DataframeAnalyticsAuthorization.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DataframeAnalyticsAuthorization.java new file mode 100644 index 000000000..5ff367757 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/DataframeAnalyticsAuthorization.java @@ -0,0 +1,258 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package co.elastic.clients.elasticsearch.ml; + +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; + +// typedef: ml._types.DataframeAnalyticsAuthorization + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class DataframeAnalyticsAuthorization implements JsonpSerializable { + @Nullable + private final ApiKeyAuthorization apiKey; + + private final List roles; + + @Nullable + private final String serviceAccount; + + // --------------------------------------------------------------------------------------------- + + private DataframeAnalyticsAuthorization(Builder builder) { + + this.apiKey = builder.apiKey; + this.roles = ApiTypeHelper.unmodifiable(builder.roles); + this.serviceAccount = builder.serviceAccount; + + } + + public static DataframeAnalyticsAuthorization of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * If an API key was used for the most recent update to the job, its name and + * identifier are listed in the response. + *

+ * API name: {@code api_key} + */ + @Nullable + public final ApiKeyAuthorization apiKey() { + return this.apiKey; + } + + /** + * If a user ID was used for the most recent update to the job, its roles at the + * time of the update are listed in the response. + *

+ * API name: {@code roles} + */ + public final List roles() { + return this.roles; + } + + /** + * If a service account was used for the most recent update to the job, the + * account name is listed in the response. + *

+ * API name: {@code service_account} + */ + @Nullable + public final String serviceAccount() { + return this.serviceAccount; + } + + /** + * 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.apiKey != null) { + generator.writeKey("api_key"); + this.apiKey.serialize(generator, mapper); + + } + if (ApiTypeHelper.isDefined(this.roles)) { + generator.writeKey("roles"); + generator.writeStartArray(); + for (String item0 : this.roles) { + generator.write(item0); + + } + generator.writeEnd(); + + } + if (this.serviceAccount != null) { + generator.writeKey("service_account"); + generator.write(this.serviceAccount); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DataframeAnalyticsAuthorization}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private ApiKeyAuthorization apiKey; + + @Nullable + private List roles; + + @Nullable + private String serviceAccount; + + /** + * If an API key was used for the most recent update to the job, its name and + * identifier are listed in the response. + *

+ * API name: {@code api_key} + */ + public final Builder apiKey(@Nullable ApiKeyAuthorization value) { + this.apiKey = value; + return this; + } + + /** + * If an API key was used for the most recent update to the job, its name and + * identifier are listed in the response. + *

+ * API name: {@code api_key} + */ + public final Builder apiKey(Function> fn) { + return this.apiKey(fn.apply(new ApiKeyAuthorization.Builder()).build()); + } + + /** + * If a user ID was used for the most recent update to the job, its roles at the + * time of the update are listed in the response. + *

+ * 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; + } + + /** + * If a user ID was used for the most recent update to the job, its roles at the + * time of the update are listed in the response. + *

+ * 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; + } + + /** + * If a service account was used for the most recent update to the job, the + * account name is listed in the response. + *

+ * API name: {@code service_account} + */ + public final Builder serviceAccount(@Nullable String value) { + this.serviceAccount = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link DataframeAnalyticsAuthorization}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DataframeAnalyticsAuthorization build() { + _checkSingleUse(); + + return new DataframeAnalyticsAuthorization(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DataframeAnalyticsAuthorization} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, DataframeAnalyticsAuthorization::setupDataframeAnalyticsAuthorizationDeserializer); + + protected static void setupDataframeAnalyticsAuthorizationDeserializer( + ObjectDeserializer op) { + + op.add(Builder::apiKey, ApiKeyAuthorization._DESERIALIZER, "api_key"); + op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "roles"); + op.add(Builder::serviceAccount, JsonpDeserializer.stringDeserializer(), "service_account"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/TransformAuthorization.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/TransformAuthorization.java new file mode 100644 index 000000000..d3d1bed49 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/TransformAuthorization.java @@ -0,0 +1,257 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package co.elastic.clients.elasticsearch.ml; + +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; + +// typedef: ml._types.TransformAuthorization + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class TransformAuthorization implements JsonpSerializable { + @Nullable + private final ApiKeyAuthorization apiKey; + + private final List roles; + + @Nullable + private final String serviceAccount; + + // --------------------------------------------------------------------------------------------- + + private TransformAuthorization(Builder builder) { + + this.apiKey = builder.apiKey; + this.roles = ApiTypeHelper.unmodifiable(builder.roles); + this.serviceAccount = builder.serviceAccount; + + } + + public static TransformAuthorization of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * If an API key was used for the most recent update to the transform, its name + * and identifier are listed in the response. + *

+ * API name: {@code api_key} + */ + @Nullable + public final ApiKeyAuthorization apiKey() { + return this.apiKey; + } + + /** + * If a user ID was used for the most recent update to the transform, its roles + * at the time of the update are listed in the response. + *

+ * API name: {@code roles} + */ + public final List roles() { + return this.roles; + } + + /** + * If a service account was used for the most recent update to the transform, + * the account name is listed in the response. + *

+ * API name: {@code service_account} + */ + @Nullable + public final String serviceAccount() { + return this.serviceAccount; + } + + /** + * 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.apiKey != null) { + generator.writeKey("api_key"); + this.apiKey.serialize(generator, mapper); + + } + if (ApiTypeHelper.isDefined(this.roles)) { + generator.writeKey("roles"); + generator.writeStartArray(); + for (String item0 : this.roles) { + generator.write(item0); + + } + generator.writeEnd(); + + } + if (this.serviceAccount != null) { + generator.writeKey("service_account"); + generator.write(this.serviceAccount); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link TransformAuthorization}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private ApiKeyAuthorization apiKey; + + @Nullable + private List roles; + + @Nullable + private String serviceAccount; + + /** + * If an API key was used for the most recent update to the transform, its name + * and identifier are listed in the response. + *

+ * API name: {@code api_key} + */ + public final Builder apiKey(@Nullable ApiKeyAuthorization value) { + this.apiKey = value; + return this; + } + + /** + * If an API key was used for the most recent update to the transform, its name + * and identifier are listed in the response. + *

+ * API name: {@code api_key} + */ + public final Builder apiKey(Function> fn) { + return this.apiKey(fn.apply(new ApiKeyAuthorization.Builder()).build()); + } + + /** + * If a user ID was used for the most recent update to the transform, its roles + * at the time of the update are listed in the response. + *

+ * 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; + } + + /** + * If a user ID was used for the most recent update to the transform, its roles + * at the time of the update are listed in the response. + *

+ * 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; + } + + /** + * If a service account was used for the most recent update to the transform, + * the account name is listed in the response. + *

+ * API name: {@code service_account} + */ + public final Builder serviceAccount(@Nullable String value) { + this.serviceAccount = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link TransformAuthorization}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public TransformAuthorization build() { + _checkSingleUse(); + + return new TransformAuthorization(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link TransformAuthorization} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, TransformAuthorization::setupTransformAuthorizationDeserializer); + + protected static void setupTransformAuthorizationDeserializer( + ObjectDeserializer op) { + + op.add(Builder::apiKey, ApiKeyAuthorization._DESERIALIZER, "api_key"); + op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "roles"); + op.add(Builder::serviceAccount, JsonpDeserializer.stringDeserializer(), "service_account"); + + } + +} diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java index ab9b94c35..6ae3c6227 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java @@ -29,6 +29,7 @@ import co.elastic.clients.elasticsearch.indices.CreateIndexRequest; import co.elastic.clients.elasticsearch.indices.GetFieldMappingRequest; import co.elastic.clients.elasticsearch.indices.GetFieldMappingResponse; +import co.elastic.clients.elasticsearch.indices.IndexSettings; import co.elastic.clients.elasticsearch.model.ModelTestCase; import co.elastic.clients.elasticsearch.snapshot.RestoreResponse; import co.elastic.clients.json.JsonData; @@ -47,6 +48,27 @@ */ public class SpecIssuesTest extends ModelTestCase { + @Test + public void i0328_charFilter() throws Exception { + // Both mappings and mappings_path are optional + String json = + "{\n" + + " \"analysis\": { \n" + + " \"char_filter\": {\n" + + " \"multi_char_filter\": {\n" + + " \"type\": \"mapping\",\n" + +// " \"mappings\": [\n" + +// " \"xyz => xyz\"\n" + +// " ],\n" + + " \"mappings_path\": \"analysis/multi-char-replacement.txt\"\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + + IndexSettings.of(b -> b.withJson(new StringReader(json))); + } + @Disabled("Not fixed yet") @Test public void i0201_restoreResponse() throws Exception {