diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InlineScript.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InlineScript.java deleted file mode 100644 index a5218423b..000000000 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InlineScript.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package co.elastic.clients.elasticsearch._types; - -import co.elastic.clients.json.JsonpDeserializable; -import co.elastic.clients.json.JsonpDeserializer; -import co.elastic.clients.json.JsonpMapper; -import co.elastic.clients.json.ObjectBuilderDeserializer; -import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; -import co.elastic.clients.util.ObjectBuilder; -import jakarta.json.stream.JsonGenerator; -import java.lang.String; -import java.util.Map; -import java.util.Objects; -import java.util.function.Function; -import javax.annotation.Nullable; - -//---------------------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------------------- -// -// This code is generated from the Elasticsearch API specification -// at https://github.com/elastic/elasticsearch-specification -// -// Manual updates to this file will be lost when the code is -// re-generated. -// -// If you find a property that is missing or wrongly typed, please -// open an issue or a PR on the API specification repository. -// -//---------------------------------------------------------------- - -// typedef: _types.InlineScript - -/** - * - * @see API - * specification - */ -@JsonpDeserializable -public class InlineScript extends ScriptBase { - @Nullable - private final String lang; - - private final Map options; - - private final String source; - - // --------------------------------------------------------------------------------------------- - - private InlineScript(Builder builder) { - super(builder); - - this.lang = builder.lang; - this.options = ApiTypeHelper.unmodifiable(builder.options); - this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); - - } - - public static InlineScript of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Specifies the language the script is written in. - *

- * API name: {@code lang} - */ - @Nullable - public final String lang() { - return this.lang; - } - - /** - * API name: {@code options} - */ - public final Map options() { - return this.options; - } - - /** - * Required - The script source. - *

- * API name: {@code source} - */ - public final String source() { - return this.source; - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - super.serializeInternal(generator, mapper); - if (this.lang != null) { - generator.writeKey("lang"); - generator.write(this.lang); - - } - if (ApiTypeHelper.isDefined(this.options)) { - generator.writeKey("options"); - generator.writeStartObject(); - for (Map.Entry item0 : this.options.entrySet()) { - generator.writeKey(item0.getKey()); - generator.write(item0.getValue()); - - } - generator.writeEnd(); - - } - generator.writeKey("source"); - generator.write(this.source); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link InlineScript}. - */ - - public static class Builder extends ScriptBase.AbstractBuilder implements ObjectBuilder { - @Nullable - private String lang; - - @Nullable - private Map options; - - private String source; - - /** - * Specifies the language the script is written in. - *

- * API name: {@code lang} - */ - public final Builder lang(@Nullable String value) { - this.lang = value; - return this; - } - - /** - * Specifies the language the script is written in. - *

- * API name: {@code lang} - */ - public final Builder lang(@Nullable ScriptLanguage value) { - this.lang = value == null ? null : value.jsonValue(); - return this; - } - - /** - * API name: {@code options} - *

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

- * Adds an entry to options. - */ - public final Builder options(String key, String value) { - this.options = _mapPut(this.options, key, value); - return this; - } - - /** - * Required - The script source. - *

- * API name: {@code source} - */ - public final Builder source(String value) { - this.source = value; - return this; - } - - @Override - protected Builder self() { - return this; - } - - /** - * Builds a {@link InlineScript}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public InlineScript build() { - _checkSingleUse(); - - return new InlineScript(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link InlineScript} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - InlineScript::setupInlineScriptDeserializer); - - protected static void setupInlineScriptDeserializer(ObjectDeserializer op) { - ScriptBase.setupScriptBaseDeserializer(op); - op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang"); - op.add(Builder::options, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), - "options"); - op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); - - op.shortcutProperty("source"); - - } - -} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/Script.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/Script.java index 2a48a2ea6..8bd09962b 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/Script.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/Script.java @@ -19,20 +19,22 @@ package co.elastic.clients.elasticsearch._types; +import co.elastic.clients.elasticsearch._types.query_dsl.IntervalsFilter; +import co.elastic.clients.elasticsearch._types.query_dsl.IntervalsFilterVariant; +import co.elastic.clients.json.JsonData; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.JsonpSerializable; import co.elastic.clients.json.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.json.UnionDeserializer; import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; -import co.elastic.clients.util.ObjectBuilderBase; -import co.elastic.clients.util.TaggedUnion; -import co.elastic.clients.util.TaggedUnionUtils; +import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; -import java.lang.Object; +import java.lang.String; +import java.util.Map; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -59,35 +61,29 @@ * @see API specification */ @JsonpDeserializable -public class Script implements TaggedUnion, JsonpSerializable { +public class Script implements IntervalsFilterVariant, JsonpSerializable { + @Nullable + private final String source; - public enum Kind { - Inline, Stored + @Nullable + private final String id; - } + private final Map params; - private final Kind _kind; - private final Object _value; + @Nullable + private final String lang; - @Override - public final Kind _kind() { - return _kind; - } + private final Map options; - @Override - public final Object _get() { - return _value; - } - - private Script(Kind kind, Object value) { - this._kind = kind; - this._value = value; - } + // --------------------------------------------------------------------------------------------- private Script(Builder builder) { - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); - this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + this.source = builder.source; + this.id = builder.id; + this.params = ApiTypeHelper.unmodifiable(builder.params); + this.lang = builder.lang; + this.options = ApiTypeHelper.unmodifiable(builder.options); } @@ -96,43 +92,107 @@ public static Script of(Function> fn) { } /** - * Is this variant instance of kind {@code inline}? + * IntervalsFilter variant kind. */ - public boolean isInline() { - return _kind == Kind.Inline; + @Override + public IntervalsFilter.Kind _intervalsFilterKind() { + return IntervalsFilter.Kind.Script; } /** - * Get the {@code inline} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code inline} kind. + * The script source. + *

+ * API name: {@code source} */ - public InlineScript inline() { - return TaggedUnionUtils.get(this, Kind.Inline); + @Nullable + public final String source() { + return this.source; } /** - * Is this variant instance of kind {@code stored}? + * The id for a stored script. + *

+ * API name: {@code id} */ - public boolean isStored() { - return _kind == Kind.Stored; + @Nullable + public final String id() { + return this.id; } /** - * Get the {@code stored} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code stored} kind. + * Specifies any named parameters that are passed into the script as variables. + * Use parameters instead of hard-coded values to decrease compile time. + *

+ * API name: {@code params} */ - public StoredScriptId stored() { - return TaggedUnionUtils.get(this, Kind.Stored); + public final Map params() { + return this.params; } - @Override + /** + * Specifies the language the script is written in. + *

+ * API name: {@code lang} + */ + @Nullable + public final String lang() { + return this.lang; + } + + /** + * API name: {@code options} + */ + public final Map options() { + return this.options; + } + + /** + * Serialize this object to JSON. + */ public void serialize(JsonGenerator generator, JsonpMapper mapper) { - if (_value instanceof JsonpSerializable) { - ((JsonpSerializable) _value).serialize(generator, mapper); + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.source != null) { + generator.writeKey("source"); + generator.write(this.source); + + } + if (this.id != null) { + generator.writeKey("id"); + generator.write(this.id); + + } + if (ApiTypeHelper.isDefined(this.params)) { + generator.writeKey("params"); + generator.writeStartObject(); + for (Map.Entry item0 : this.params.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (this.lang != null) { + generator.writeKey("lang"); + generator.write(this.lang); + + } + if (ApiTypeHelper.isDefined(this.options)) { + generator.writeKey("options"); + generator.writeStartObject(); + for (Map.Entry item0 : this.options.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); + + } + generator.writeEnd(); + } } @@ -142,43 +202,151 @@ public String toString() { return JsonpUtils.toString(this); } - public static class Builder extends ObjectBuilderBase implements ObjectBuilder - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/search_application/SearchApplicationTemplate.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/search_application/SearchApplicationTemplate.java index eb23a20d2..fb022486f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/search_application/SearchApplicationTemplate.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/search_application/SearchApplicationTemplate.java @@ -19,7 +19,7 @@ package co.elastic.clients.elasticsearch.search_application; -import co.elastic.clients.elasticsearch._types.InlineScript; +import co.elastic.clients.elasticsearch._types.Script; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -60,7 +60,7 @@ */ @JsonpDeserializable public class SearchApplicationTemplate implements JsonpSerializable { - private final InlineScript script; + private final Script script; // --------------------------------------------------------------------------------------------- @@ -79,7 +79,7 @@ public static SearchApplicationTemplate of(Function * API name: {@code script} */ - public final InlineScript script() { + public final Script script() { return this.script; } @@ -113,14 +113,14 @@ public String toString() { public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { - private InlineScript script; + private Script script; /** * Required - The associated mustache template. *

* API name: {@code script} */ - public final Builder script(InlineScript value) { + public final Builder script(Script value) { this.script = value; return this; } @@ -130,8 +130,8 @@ public final Builder script(InlineScript value) { *

* API name: {@code script} */ - public final Builder script(Function> fn) { - return this.script(fn.apply(new InlineScript.Builder()).build()); + public final Builder script(Function> fn) { + return this.script(fn.apply(new Script.Builder()).build()); } @Override @@ -163,7 +163,7 @@ public SearchApplicationTemplate build() { protected static void setupSearchApplicationTemplateDeserializer( ObjectDeserializer op) { - op.add(Builder::script, InlineScript._DESERIALIZER, "script"); + op.add(Builder::script, Script._DESERIALIZER, "script"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateInlineScript.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateInlineScript.java deleted file mode 100644 index 6984132cb..000000000 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateInlineScript.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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.ScriptBase; -import co.elastic.clients.elasticsearch._types.ScriptLanguage; -import co.elastic.clients.json.JsonpDeserializable; -import co.elastic.clients.json.JsonpDeserializer; -import co.elastic.clients.json.JsonpMapper; -import co.elastic.clients.json.ObjectBuilderDeserializer; -import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; -import co.elastic.clients.util.ObjectBuilder; -import jakarta.json.stream.JsonGenerator; -import java.lang.String; -import java.util.Map; -import java.util.Objects; -import java.util.function.Function; -import javax.annotation.Nullable; - -//---------------------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------------------- -// -// This code is generated from the Elasticsearch API specification -// at https://github.com/elastic/elasticsearch-specification -// -// Manual updates to this file will be lost when the code is -// re-generated. -// -// If you find a property that is missing or wrongly typed, please -// open an issue or a PR on the API specification repository. -// -//---------------------------------------------------------------- - -// typedef: security._types.RoleTemplateInlineScript - -/** - * - * @see API - * specification - */ -@JsonpDeserializable -public class RoleTemplateInlineScript extends ScriptBase { - @Nullable - private final String lang; - - private final Map options; - - private final RoleTemplateInlineQuery source; - - // --------------------------------------------------------------------------------------------- - - private RoleTemplateInlineScript(Builder builder) { - super(builder); - - this.lang = builder.lang; - this.options = ApiTypeHelper.unmodifiable(builder.options); - this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); - - } - - public static RoleTemplateInlineScript of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * API name: {@code lang} - */ - @Nullable - public final String lang() { - return this.lang; - } - - /** - * API name: {@code options} - */ - public final Map options() { - return this.options; - } - - /** - * Required - API name: {@code source} - */ - public final RoleTemplateInlineQuery source() { - return this.source; - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - super.serializeInternal(generator, mapper); - if (this.lang != null) { - generator.writeKey("lang"); - generator.write(this.lang); - - } - if (ApiTypeHelper.isDefined(this.options)) { - generator.writeKey("options"); - generator.writeStartObject(); - for (Map.Entry item0 : this.options.entrySet()) { - generator.writeKey(item0.getKey()); - generator.write(item0.getValue()); - - } - generator.writeEnd(); - - } - generator.writeKey("source"); - this.source.serialize(generator, mapper); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link RoleTemplateInlineScript}. - */ - - public static class Builder extends ScriptBase.AbstractBuilder - implements - ObjectBuilder { - @Nullable - private String lang; - - @Nullable - private Map options; - - private RoleTemplateInlineQuery source; - - /** - * API name: {@code lang} - */ - public final Builder lang(@Nullable String value) { - this.lang = value; - return this; - } - - /** - * API name: {@code lang} - */ - public final Builder lang(@Nullable ScriptLanguage value) { - this.lang = value == null ? null : value.jsonValue(); - return this; - } - - /** - * API name: {@code options} - *

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

- * Adds an entry to options. - */ - public final Builder options(String key, String value) { - this.options = _mapPut(this.options, key, value); - return this; - } - - /** - * Required - API name: {@code source} - */ - public final Builder source(RoleTemplateInlineQuery value) { - this.source = value; - return this; - } - - /** - * Required - API name: {@code source} - */ - public final Builder source( - Function> fn) { - return this.source(fn.apply(new RoleTemplateInlineQuery.Builder()).build()); - } - - @Override - protected Builder self() { - return this; - } - - /** - * Builds a {@link RoleTemplateInlineScript}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public RoleTemplateInlineScript build() { - _checkSingleUse(); - - return new RoleTemplateInlineScript(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link RoleTemplateInlineScript} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, RoleTemplateInlineScript::setupRoleTemplateInlineScriptDeserializer); - - protected static void setupRoleTemplateInlineScriptDeserializer( - ObjectDeserializer op) { - ScriptBase.setupScriptBaseDeserializer(op); - op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang"); - op.add(Builder::options, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), - "options"); - op.add(Builder::source, RoleTemplateInlineQuery._DESERIALIZER, "source"); - - op.shortcutProperty("source"); - - } - -} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateScript.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateScript.java index 6b07ec241..f23a00872 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateScript.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateScript.java @@ -19,21 +19,21 @@ package co.elastic.clients.elasticsearch.security; -import co.elastic.clients.elasticsearch._types.StoredScriptId; +import co.elastic.clients.elasticsearch._types.ScriptLanguage; +import co.elastic.clients.json.JsonData; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.JsonpSerializable; import co.elastic.clients.json.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.json.UnionDeserializer; import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; -import co.elastic.clients.util.ObjectBuilderBase; -import co.elastic.clients.util.TaggedUnion; -import co.elastic.clients.util.TaggedUnionUtils; +import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; -import java.lang.Object; +import java.lang.String; +import java.util.Map; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -62,35 +62,29 @@ * specification */ @JsonpDeserializable -public class RoleTemplateScript implements TaggedUnion, JsonpSerializable { +public class RoleTemplateScript implements JsonpSerializable { + @Nullable + private final RoleTemplateInlineQuery source; - public enum Kind { - Stored, Inline + @Nullable + private final String id; - } - - private final Kind _kind; - private final Object _value; + private final Map params; - @Override - public final Kind _kind() { - return _kind; - } + @Nullable + private final String lang; - @Override - public final Object _get() { - return _value; - } + private final Map options; - private RoleTemplateScript(Kind kind, Object value) { - this._kind = kind; - this._value = value; - } + // --------------------------------------------------------------------------------------------- private RoleTemplateScript(Builder builder) { - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); - this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + this.source = builder.source; + this.id = builder.id; + this.params = ApiTypeHelper.unmodifiable(builder.params); + this.lang = builder.lang; + this.options = ApiTypeHelper.unmodifiable(builder.options); } @@ -99,43 +93,97 @@ public static RoleTemplateScript of(Functionid for a stored script. + *

+ * API name: {@code id} */ - public StoredScriptId stored() { - return TaggedUnionUtils.get(this, Kind.Stored); + @Nullable + public final String id() { + return this.id; } /** - * Is this variant instance of kind {@code inline}? + * Specifies any named parameters that are passed into the script as variables. + * Use parameters instead of hard-coded values to decrease compile time. + *

+ * API name: {@code params} */ - public boolean isInline() { - return _kind == Kind.Inline; + public final Map params() { + return this.params; } /** - * Get the {@code inline} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code inline} kind. + * Specifies the language the script is written in. + *

+ * API name: {@code lang} */ - public RoleTemplateInlineScript inline() { - return TaggedUnionUtils.get(this, Kind.Inline); + @Nullable + public final String lang() { + return this.lang; } - @Override + /** + * API name: {@code options} + */ + public final Map options() { + return this.options; + } + + /** + * Serialize this object to JSON. + */ public void serialize(JsonGenerator generator, JsonpMapper mapper) { - if (_value instanceof JsonpSerializable) { - ((JsonpSerializable) _value).serialize(generator, mapper); + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.source != null) { + generator.writeKey("source"); + this.source.serialize(generator, mapper); + + } + if (this.id != null) { + generator.writeKey("id"); + generator.write(this.id); + + } + if (ApiTypeHelper.isDefined(this.params)) { + generator.writeKey("params"); + generator.writeStartObject(); + for (Map.Entry item0 : this.params.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (this.lang != null) { + generator.writeKey("lang"); + generator.write(this.lang); + + } + if (ApiTypeHelper.isDefined(this.options)) { + generator.writeKey("options"); + generator.writeStartObject(); + for (Map.Entry item0 : this.options.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); + + } + generator.writeEnd(); + } } @@ -145,45 +193,159 @@ public String toString() { return JsonpUtils.toString(this); } - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Kind _kind; - private Object _value; + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RoleTemplateScript}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private RoleTemplateInlineQuery source; - public ObjectBuilder stored(StoredScriptId v) { - this._kind = Kind.Stored; - this._value = v; + @Nullable + private String id; + + @Nullable + private Map params; + + @Nullable + private String lang; + + @Nullable + private Map options; + + /** + * API name: {@code source} + */ + public final Builder source(@Nullable RoleTemplateInlineQuery value) { + this.source = value; + return this; + } + + /** + * API name: {@code source} + */ + public final Builder source( + Function> fn) { + return this.source(fn.apply(new RoleTemplateInlineQuery.Builder()).build()); + } + + /** + * The id for a stored script. + *

+ * API name: {@code id} + */ + public final Builder id(@Nullable String value) { + this.id = value; + return this; + } + + /** + * Specifies any named parameters that are passed into the script as variables. + * Use parameters instead of hard-coded values to decrease compile time. + *

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

+ * Adds all entries of map to params. + */ + public final Builder params(Map map) { + this.params = _mapPutAll(this.params, map); + return this; + } + + /** + * Specifies any named parameters that are passed into the script as variables. + * Use parameters instead of hard-coded values to decrease compile time. + *

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

+ * Adds an entry to params. + */ + public final Builder params(String key, JsonData value) { + this.params = _mapPut(this.params, key, value); + return this; + } + + /** + * Specifies the language the script is written in. + *

+ * API name: {@code lang} + */ + public final Builder lang(@Nullable String value) { + this.lang = value; + return this; + } + + /** + * Specifies the language the script is written in. + *

+ * API name: {@code lang} + */ + public final Builder lang(@Nullable ScriptLanguage value) { + this.lang = value == null ? null : value.jsonValue(); return this; } - public ObjectBuilder stored( - Function> fn) { - return this.stored(fn.apply(new StoredScriptId.Builder()).build()); + /** + * API name: {@code options} + *

+ * Adds all entries of map to options. + */ + public final Builder options(Map map) { + this.options = _mapPutAll(this.options, map); + return this; } - public ObjectBuilder inline(RoleTemplateInlineScript v) { - this._kind = Kind.Inline; - this._value = v; + /** + * API name: {@code options} + *

+ * Adds an entry to options. + */ + public final Builder options(String key, String value) { + this.options = _mapPut(this.options, key, value); return this; } - public ObjectBuilder inline( - Function> fn) { - return this.inline(fn.apply(new RoleTemplateInlineScript.Builder()).build()); + @Override + protected Builder self() { + return this; } + /** + * Builds a {@link RoleTemplateScript}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ public RoleTemplateScript build() { _checkSingleUse(); + return new RoleTemplateScript(this); } - } - private static JsonpDeserializer buildRoleTemplateScriptDeserializer() { - return new UnionDeserializer.Builder(RoleTemplateScript::new, false) - .addMember(Kind.Stored, StoredScriptId._DESERIALIZER) - .addMember(Kind.Inline, RoleTemplateInlineScript._DESERIALIZER).build(); + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RoleTemplateScript} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, RoleTemplateScript::setupRoleTemplateScriptDeserializer); + + protected static void setupRoleTemplateScriptDeserializer(ObjectDeserializer op) { + + op.add(Builder::source, RoleTemplateInlineQuery._DESERIALIZER, "source"); + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(Builder::params, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "params"); + op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang"); + op.add(Builder::options, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), + "options"); + + op.shortcutProperty("source"); + } - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer - .lazy(RoleTemplateScript::buildRoleTemplateScriptDeserializer); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateScriptBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateScriptBuilders.java deleted file mode 100644 index 55f8f5224..000000000 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/RoleTemplateScriptBuilders.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.StoredScriptId; -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 RoleTemplateScript} variants. - */ -public class RoleTemplateScriptBuilders { - private RoleTemplateScriptBuilders() { - } - - /** - * Creates a builder for the {@link StoredScriptId stored} - * {@code RoleTemplateScript} variant. - */ - public static StoredScriptId.Builder stored() { - return new StoredScriptId.Builder(); - } - - /** - * Creates a builder for the {@link RoleTemplateInlineScript inline} - * {@code RoleTemplateScript} variant. - */ - public static RoleTemplateInlineScript.Builder inline() { - return new RoleTemplateInlineScript.Builder(); - } - -}