Skip to content

Commit

Permalink
Update API spec, fix some spec-related java client issues (#344) (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
swallez authored Jul 12, 2022
1 parent 4c2e1a8 commit bfdd07b
Show file tree
Hide file tree
Showing 30 changed files with 1,191 additions and 401 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import java.util.function.Function;
import javax.annotation.Nullable;

// typedef: _types.Time
// typedef: _types.Duration

/**
* Whenever durations need to be specified, e.g. for a timeout parameter, the
Expand All @@ -52,7 +52,8 @@
* @see <a href=
* "https://github.com/elastic/elasticsearch/blob/master/libs/core/src/main/java/org/elasticsearch/core/TimeValue.java">Documentation
* on elastic.co</a>
* @see <a href="../doc-files/api-spec.html#_types.Time">API specification</a>
* @see <a href="../doc-files/api-spec.html#_types.Duration">API
* specification</a>
*/
@JsonpDeserializable
public class Time implements TaggedUnion<Time.Kind, Object>, JsonpSerializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package co.elastic.clients.elasticsearch._types.aggregations;

import co.elastic.clients.elasticsearch._types.Script;
import co.elastic.clients.elasticsearch._types.SortOrder;
import co.elastic.clients.elasticsearch._types.Time;
import co.elastic.clients.elasticsearch.transform.PivotGroupBy;
import co.elastic.clients.elasticsearch.transform.PivotGroupByVariant;
Expand All @@ -34,11 +35,13 @@
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.NamedValue;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
Expand Down Expand Up @@ -84,8 +87,7 @@ public class DateHistogramAggregation extends BucketAggregationBase implements A
@Nullable
private final Time offset;

@Nullable
private final HistogramOrder order;
private final List<NamedValue<SortOrder>> order;

private final Map<String, JsonData> params;

Expand Down Expand Up @@ -113,7 +115,7 @@ private DateHistogramAggregation(Builder builder) {
this.minDocCount = builder.minDocCount;
this.missing = builder.missing;
this.offset = builder.offset;
this.order = builder.order;
this.order = ApiTypeHelper.unmodifiable(builder.order);
this.params = ApiTypeHelper.unmodifiable(builder.params);
this.script = builder.script;
this.timeZone = builder.timeZone;
Expand Down Expand Up @@ -224,8 +226,7 @@ public final Time offset() {
/**
* API name: {@code order}
*/
@Nullable
public final HistogramOrder order() {
public final List<NamedValue<SortOrder>> order() {
return this.order;
}

Expand Down Expand Up @@ -312,9 +313,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
this.offset.serialize(generator, mapper);

}
if (this.order != null) {
if (ApiTypeHelper.isDefined(this.order)) {
generator.writeKey("order");
this.order.serialize(generator, mapper);
generator.writeStartArray();
for (NamedValue<SortOrder> item0 : this.order) {
generator.writeStartObject();
generator.writeKey(item0.name());
item0.value().serialize(generator, mapper);
generator.writeEnd();

}
generator.writeEnd();

}
if (ApiTypeHelper.isDefined(this.params)) {
Expand Down Expand Up @@ -386,7 +395,7 @@ public static class Builder extends BucketAggregationBase.AbstractBuilder<Builde
private Time offset;

@Nullable
private HistogramOrder order;
private List<NamedValue<SortOrder>> order;

@Nullable
private Map<String, JsonData> params;
Expand Down Expand Up @@ -519,17 +528,22 @@ public final Builder offset(Function<Time.Builder, ObjectBuilder<Time>> fn) {

/**
* API name: {@code order}
* <p>
* Adds all elements of <code>list</code> to <code>order</code>.
*/
public final Builder order(@Nullable HistogramOrder value) {
this.order = value;
public final Builder order(List<NamedValue<SortOrder>> list) {
this.order = _listAddAll(this.order, list);
return this;
}

/**
* API name: {@code order}
* <p>
* Adds one or more values to <code>order</code>.
*/
public final Builder order(Function<HistogramOrder.Builder, ObjectBuilder<HistogramOrder>> fn) {
return this.order(fn.apply(new HistogramOrder.Builder()).build());
public final Builder order(NamedValue<SortOrder> value, NamedValue<SortOrder>... values) {
this.order = _listAdd(this.order, value, values);
return this;
}

/**
Expand Down Expand Up @@ -624,7 +638,8 @@ protected static void setupDateHistogramAggregationDeserializer(
op.add(Builder::minDocCount, JsonpDeserializer.integerDeserializer(), "min_doc_count");
op.add(Builder::missing, JsonpDeserializer.stringDeserializer(), "missing");
op.add(Builder::offset, Time._DESERIALIZER, "offset");
op.add(Builder::order, HistogramOrder._DESERIALIZER, "order");
op.add(Builder::order,
JsonpDeserializer.arrayDeserializer(NamedValue.deserializer(() -> SortOrder._DESERIALIZER)), "order");
op.add(Builder::params, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "params");
op.add(Builder::script, Script._DESERIALIZER, "script");
op.add(Builder::timeZone, JsonpDeserializer.stringDeserializer(), "time_zone");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,23 @@
package co.elastic.clients.elasticsearch._types.aggregations;

import co.elastic.clients.elasticsearch._types.Script;
import co.elastic.clients.elasticsearch._types.SortOrder;
import co.elastic.clients.elasticsearch.transform.PivotGroupBy;
import co.elastic.clients.elasticsearch.transform.PivotGroupByVariant;
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.NamedValue;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.Boolean;
import java.lang.Double;
import java.lang.Integer;
import java.lang.String;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -72,8 +76,7 @@ public class HistogramAggregation extends BucketAggregationBase implements Aggre
@Nullable
private final Double offset;

@Nullable
private final HistogramOrder order;
private final List<NamedValue<SortOrder>> order;

@Nullable
private final Script script;
Expand All @@ -96,7 +99,7 @@ private HistogramAggregation(Builder builder) {
this.minDocCount = builder.minDocCount;
this.missing = builder.missing;
this.offset = builder.offset;
this.order = builder.order;
this.order = ApiTypeHelper.unmodifiable(builder.order);
this.script = builder.script;
this.format = builder.format;
this.keyed = builder.keyed;
Expand Down Expand Up @@ -182,8 +185,7 @@ public final Double offset() {
/**
* API name: {@code order}
*/
@Nullable
public final HistogramOrder order() {
public final List<NamedValue<SortOrder>> order() {
return this.order;
}

Expand Down Expand Up @@ -249,9 +251,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.write(this.offset);

}
if (this.order != null) {
if (ApiTypeHelper.isDefined(this.order)) {
generator.writeKey("order");
this.order.serialize(generator, mapper);
generator.writeStartArray();
for (NamedValue<SortOrder> item0 : this.order) {
generator.writeStartObject();
generator.writeKey(item0.name());
item0.value().serialize(generator, mapper);
generator.writeEnd();

}
generator.writeEnd();

}
if (this.script != null) {
Expand Down Expand Up @@ -303,7 +313,7 @@ public static class Builder extends BucketAggregationBase.AbstractBuilder<Builde
private Double offset;

@Nullable
private HistogramOrder order;
private List<NamedValue<SortOrder>> order;

@Nullable
private Script script;
Expand Down Expand Up @@ -388,17 +398,22 @@ public final Builder offset(@Nullable Double value) {

/**
* API name: {@code order}
* <p>
* Adds all elements of <code>list</code> to <code>order</code>.
*/
public final Builder order(@Nullable HistogramOrder value) {
this.order = value;
public final Builder order(List<NamedValue<SortOrder>> list) {
this.order = _listAddAll(this.order, list);
return this;
}

/**
* API name: {@code order}
* <p>
* Adds one or more values to <code>order</code>.
*/
public final Builder order(Function<HistogramOrder.Builder, ObjectBuilder<HistogramOrder>> fn) {
return this.order(fn.apply(new HistogramOrder.Builder()).build());
public final Builder order(NamedValue<SortOrder> value, NamedValue<SortOrder>... values) {
this.order = _listAdd(this.order, value, values);
return this;
}

/**
Expand Down Expand Up @@ -470,7 +485,8 @@ protected static void setupHistogramAggregationDeserializer(ObjectDeserializer<H
op.add(Builder::minDocCount, JsonpDeserializer.integerDeserializer(), "min_doc_count");
op.add(Builder::missing, JsonpDeserializer.doubleDeserializer(), "missing");
op.add(Builder::offset, JsonpDeserializer.doubleDeserializer(), "offset");
op.add(Builder::order, HistogramOrder._DESERIALIZER, "order");
op.add(Builder::order,
JsonpDeserializer.arrayDeserializer(NamedValue.deserializer(() -> SortOrder._DESERIALIZER)), "order");
op.add(Builder::script, Script._DESERIALIZER, "script");
op.add(Builder::format, JsonpDeserializer.stringDeserializer(), "format");
op.add(Builder::keyed, JsonpDeserializer.booleanDeserializer(), "keyed");
Expand Down
Loading

0 comments on commit bfdd07b

Please sign in to comment.