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.