Skip to content

Commit

Permalink
partial fixes from api-spec pr 2485
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta committed Apr 5, 2024
1 parent 5d3be4c commit 789e51d
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import co.elastic.clients.json.NamedDeserializer;
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;
Expand Down Expand Up @@ -62,8 +61,10 @@
*/
@JsonpDeserializable
public class ExtendedBounds<T> implements JsonpSerializable {
@Nullable
private final T max;

@Nullable
private final T min;

@Nullable
Expand All @@ -73,8 +74,8 @@ public class ExtendedBounds<T> implements JsonpSerializable {

private ExtendedBounds(Builder<T> builder) {

this.max = ApiTypeHelper.requireNonNull(builder.max, this, "max");
this.min = ApiTypeHelper.requireNonNull(builder.min, this, "min");
this.max = builder.max;
this.min = builder.min;
this.tSerializer = builder.tSerializer;

}
Expand All @@ -84,19 +85,21 @@ public static <T> ExtendedBounds<T> of(Function<Builder<T>, ObjectBuilder<Extend
}

/**
* Required - Maximum value for the bound.
* Maximum value for the bound.
* <p>
* API name: {@code max}
*/
@Nullable
public final T max() {
return this.max;
}

/**
* Required - Minimum value for the bound.
* Minimum value for the bound.
* <p>
* API name: {@code min}
*/
@Nullable
public final T min() {
return this.min;
}
Expand All @@ -112,11 +115,16 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.writeKey("max");
JsonpUtils.serialize(this.max, generator, tSerializer, mapper);
if (this.max != null) {
generator.writeKey("max");
JsonpUtils.serialize(this.max, generator, tSerializer, mapper);

generator.writeKey("min");
JsonpUtils.serialize(this.min, generator, tSerializer, mapper);
}
if (this.min != null) {
generator.writeKey("min");
JsonpUtils.serialize(this.min, generator, tSerializer, mapper);

}

}

Expand All @@ -134,29 +142,31 @@ public String toString() {
public static class Builder<T> extends WithJsonObjectBuilderBase<Builder<T>>
implements
ObjectBuilder<ExtendedBounds<T>> {
@Nullable
private T max;

@Nullable
private T min;

@Nullable
private JsonpSerializer<T> tSerializer;

/**
* Required - Maximum value for the bound.
* Maximum value for the bound.
* <p>
* API name: {@code max}
*/
public final Builder<T> max(T value) {
public final Builder<T> max(@Nullable T value) {
this.max = value;
return this;
}

/**
* Required - Minimum value for the bound.
* Minimum value for the bound.
* <p>
* API name: {@code min}
*/
public final Builder<T> min(T value) {
public final Builder<T> min(@Nullable T value) {
this.min = value;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package co.elastic.clients.elasticsearch._types.aggregations;

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;
Expand Down Expand Up @@ -72,6 +73,9 @@ public class VariableWidthHistogramAggregation implements AggregationVariant, Js
@Nullable
private final Integer initialBuffer;

@Nullable
private final Script script;

// ---------------------------------------------------------------------------------------------

private VariableWidthHistogramAggregation(Builder builder) {
Expand All @@ -80,6 +84,7 @@ private VariableWidthHistogramAggregation(Builder builder) {
this.buckets = builder.buckets;
this.shardSize = builder.shardSize;
this.initialBuffer = builder.initialBuffer;
this.script = builder.script;

}

Expand Down Expand Up @@ -139,6 +144,14 @@ public final Integer initialBuffer() {
return this.initialBuffer;
}

/**
* API name: {@code script}
*/
@Nullable
public final Script script() {
return this.script;
}

/**
* Serialize this object to JSON.
*/
Expand Down Expand Up @@ -170,6 +183,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.write(this.initialBuffer);

}
if (this.script != null) {
generator.writeKey("script");
this.script.serialize(generator, mapper);

}

}

Expand Down Expand Up @@ -199,6 +217,9 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder>
@Nullable
private Integer initialBuffer;

@Nullable
private Script script;

/**
* The name of the field.
* <p>
Expand Down Expand Up @@ -242,6 +263,21 @@ public final Builder initialBuffer(@Nullable Integer value) {
return this;
}

/**
* API name: {@code script}
*/
public final Builder script(@Nullable Script value) {
this.script = value;
return this;
}

/**
* API name: {@code script}
*/
public final Builder script(Function<Script.Builder, ObjectBuilder<Script>> fn) {
return this.script(fn.apply(new Script.Builder()).build());
}

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -275,6 +311,7 @@ protected static void setupVariableWidthHistogramAggregationDeserializer(
op.add(Builder::buckets, JsonpDeserializer.integerDeserializer(), "buckets");
op.add(Builder::shardSize, JsonpDeserializer.integerDeserializer(), "shard_size");
op.add(Builder::initialBuffer, JsonpDeserializer.integerDeserializer(), "initial_buffer");
op.add(Builder::script, Script._DESERIALIZER, "script");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.String;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
Expand All @@ -54,11 +58,15 @@
*/
@JsonpDeserializable
public class HtmlStripCharFilter extends CharFilterBase implements CharFilterDefinitionVariant {
private final List<String> escapedTags;

// ---------------------------------------------------------------------------------------------

private HtmlStripCharFilter(Builder builder) {
super(builder);

this.escapedTags = ApiTypeHelper.unmodifiable(builder.escapedTags);

}

public static HtmlStripCharFilter of(Function<Builder, ObjectBuilder<HtmlStripCharFilter>> fn) {
Expand All @@ -73,10 +81,27 @@ public CharFilterDefinition.Kind _charFilterDefinitionKind() {
return CharFilterDefinition.Kind.HtmlStrip;
}

/**
* API name: {@code escaped_tags}
*/
public final List<String> escapedTags() {
return this.escapedTags;
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.write("type", "html_strip");
super.serializeInternal(generator, mapper);
if (ApiTypeHelper.isDefined(this.escapedTags)) {
generator.writeKey("escaped_tags");
generator.writeStartArray();
for (String item0 : this.escapedTags) {
generator.write(item0);

}
generator.writeEnd();

}

}

Expand All @@ -89,6 +114,29 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
public static class Builder extends CharFilterBase.AbstractBuilder<Builder>
implements
ObjectBuilder<HtmlStripCharFilter> {
@Nullable
private List<String> escapedTags;

/**
* API name: {@code escaped_tags}
* <p>
* Adds all elements of <code>list</code> to <code>escapedTags</code>.
*/
public final Builder escapedTags(List<String> list) {
this.escapedTags = _listAddAll(this.escapedTags, list);
return this;
}

/**
* API name: {@code escaped_tags}
* <p>
* Adds one or more values to <code>escapedTags</code>.
*/
public final Builder escapedTags(String value, String... values) {
this.escapedTags = _listAdd(this.escapedTags, value, values);
return this;
}

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -117,6 +165,8 @@ public HtmlStripCharFilter build() {

protected static void setupHtmlStripCharFilterDeserializer(ObjectDeserializer<HtmlStripCharFilter.Builder> op) {
CharFilterBase.setupCharFilterBaseDeserializer(op);
op.add(Builder::escapedTags, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()),
"escaped_tags");

op.ignore("type");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public final String locale() {

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.write("type", "{dynamic_property}");
generator.write("type", "{dynamic_type}");
super.serializeInternal(generator, mapper);
if (this.enabled != null) {
generator.writeKey("enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public enum Kind implements JsonEnum {

DoubleRange("double_range"),

DynamicType("{dynamic_property}"),
DynamicType("{dynamic_type}"),

Alias("alias"),

Expand Down Expand Up @@ -433,18 +433,17 @@ public DoubleRangeProperty doubleRange() {
}

/**
* Is this variant instance of kind {@code {dynamic_property}}?
* Is this variant instance of kind {@code {dynamic_type}}?
*/
public boolean isDynamicType() {
return _kind == Kind.DynamicType;
}

/**
* Get the {@code {dynamic_property}} variant value.
* Get the {@code {dynamic_type}} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code {dynamic_property}}
* kind.
* if the current variant is not of the {@code {dynamic_type}} kind.
*/
public DynamicProperty dynamicType() {
return TaggedUnionUtils.get(this, Kind.DynamicType);
Expand Down Expand Up @@ -1621,7 +1620,7 @@ protected static void setupPropertyDeserializer(ObjectDeserializer<Builder> op)
op.add(Builder::denseVector, DenseVectorProperty._DESERIALIZER, "dense_vector");
op.add(Builder::double_, DoubleNumberProperty._DESERIALIZER, "double");
op.add(Builder::doubleRange, DoubleRangeProperty._DESERIALIZER, "double_range");
op.add(Builder::dynamicType, DynamicProperty._DESERIALIZER, "{dynamic_property}");
op.add(Builder::dynamicType, DynamicProperty._DESERIALIZER, "{dynamic_type}");
op.add(Builder::alias, FieldAliasProperty._DESERIALIZER, "alias");
op.add(Builder::flattened, FlattenedProperty._DESERIALIZER, "flattened");
op.add(Builder::float_, FloatNumberProperty._DESERIALIZER, "float");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ public static Property doubleRange(Function<DoubleRangeProperty.Builder, ObjectB
}

/**
* Creates a builder for the {@link DynamicProperty {dynamic_property}}
* Creates a builder for the {@link DynamicProperty {dynamic_type}}
* {@code Property} variant.
*/
public static DynamicProperty.Builder dynamicType() {
return new DynamicProperty.Builder();
}

/**
* Creates a Property of the {@link DynamicProperty {dynamic_property}}
* Creates a Property of the {@link DynamicProperty {dynamic_type}}
* {@code Property} variant.
*/
public static Property dynamicType(Function<DynamicProperty.Builder, ObjectBuilder<DynamicProperty>> fn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
public enum RuntimeFieldType implements JsonEnum {
Boolean("boolean"),

Composite("composite"),

Date("date"),

Double("double"),
Expand Down
Loading

0 comments on commit 789e51d

Please sign in to comment.