Skip to content

Commit

Permalink
[codegen] Update to the latest API spec
Browse files Browse the repository at this point in the history
  • Loading branch information
swallez committed Oct 17, 2023
1 parent 0015d8f commit 4b2b4f8
Show file tree
Hide file tree
Showing 71 changed files with 2,246 additions and 3,493 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
import co.elastic.clients.util.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.Integer;
import java.lang.String;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

// typedef: _types.ClusterStatistics

Expand All @@ -53,13 +56,25 @@ public class ClusterStatistics implements JsonpSerializable {

private final int total;

private final int running;

private final int partial;

private final int failed;

private final Map<String, ClusterDetails> details;

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

private ClusterStatistics(Builder builder) {

this.skipped = ApiTypeHelper.requireNonNull(builder.skipped, this, "skipped");
this.successful = ApiTypeHelper.requireNonNull(builder.successful, this, "successful");
this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total");
this.running = ApiTypeHelper.requireNonNull(builder.running, this, "running");
this.partial = ApiTypeHelper.requireNonNull(builder.partial, this, "partial");
this.failed = ApiTypeHelper.requireNonNull(builder.failed, this, "failed");
this.details = ApiTypeHelper.unmodifiable(builder.details);

}

Expand Down Expand Up @@ -88,6 +103,34 @@ public final int total() {
return this.total;
}

/**
* Required - API name: {@code running}
*/
public final int running() {
return this.running;
}

/**
* Required - API name: {@code partial}
*/
public final int partial() {
return this.partial;
}

/**
* Required - API name: {@code failed}
*/
public final int failed() {
return this.failed;
}

/**
* API name: {@code details}
*/
public final Map<String, ClusterDetails> details() {
return this.details;
}

/**
* Serialize this object to JSON.
*/
Expand All @@ -108,6 +151,27 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("total");
generator.write(this.total);

generator.writeKey("running");
generator.write(this.running);

generator.writeKey("partial");
generator.write(this.partial);

generator.writeKey("failed");
generator.write(this.failed);

if (ApiTypeHelper.isDefined(this.details)) {
generator.writeKey("details");
generator.writeStartObject();
for (Map.Entry<String, ClusterDetails> item0 : this.details.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);

}
generator.writeEnd();

}

}

@Override
Expand All @@ -128,6 +192,15 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder> implement

private Integer total;

private Integer running;

private Integer partial;

private Integer failed;

@Nullable
private Map<String, ClusterDetails> details;

/**
* Required - API name: {@code skipped}
*/
Expand All @@ -152,6 +225,59 @@ public final Builder total(int value) {
return this;
}

/**
* Required - API name: {@code running}
*/
public final Builder running(int value) {
this.running = value;
return this;
}

/**
* Required - API name: {@code partial}
*/
public final Builder partial(int value) {
this.partial = value;
return this;
}

/**
* Required - API name: {@code failed}
*/
public final Builder failed(int value) {
this.failed = value;
return this;
}

/**
* API name: {@code details}
* <p>
* Adds all entries of <code>map</code> to <code>details</code>.
*/
public final Builder details(Map<String, ClusterDetails> map) {
this.details = _mapPutAll(this.details, map);
return this;
}

/**
* API name: {@code details}
* <p>
* Adds an entry to <code>details</code>.
*/
public final Builder details(String key, ClusterDetails value) {
this.details = _mapPut(this.details, key, value);
return this;
}

/**
* API name: {@code details}
* <p>
* Adds an entry to <code>details</code> using a builder lambda.
*/
public final Builder details(String key, Function<ClusterDetails.Builder, ObjectBuilder<ClusterDetails>> fn) {
return details(key, fn.apply(new ClusterDetails.Builder()).build());
}

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -183,6 +309,10 @@ protected static void setupClusterStatisticsDeserializer(ObjectDeserializer<Clus
op.add(Builder::skipped, JsonpDeserializer.integerDeserializer(), "skipped");
op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful");
op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total");
op.add(Builder::running, JsonpDeserializer.integerDeserializer(), "running");
op.add(Builder::partial, JsonpDeserializer.integerDeserializer(), "partial");
op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed");
op.add(Builder::details, JsonpDeserializer.stringMapDeserializer(ClusterDetails._DESERIALIZER), "details");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public class KnnQuery implements JsonpSerializable {

private final List<Query> filter;

@Nullable
private final Float similarity;

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

private KnnQuery(Builder builder) {
Expand All @@ -79,6 +82,7 @@ private KnnQuery(Builder builder) {
this.numCandidates = ApiTypeHelper.requireNonNull(builder.numCandidates, this, "numCandidates");
this.boost = builder.boost;
this.filter = ApiTypeHelper.unmodifiable(builder.filter);
this.similarity = builder.similarity;

}

Expand Down Expand Up @@ -152,6 +156,16 @@ public final List<Query> filter() {
return this.filter;
}

/**
* The minimum similarity for a vector to be considered a match
* <p>
* API name: {@code similarity}
*/
@Nullable
public final Float similarity() {
return this.similarity;
}

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

}
if (this.similarity != null) {
generator.writeKey("similarity");
generator.write(this.similarity);

}

}

Expand Down Expand Up @@ -235,6 +254,9 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder> implement
@Nullable
private List<Query> filter;

@Nullable
private Float similarity;

/**
* Required - The name of the vector field to search against
* <p>
Expand Down Expand Up @@ -356,6 +378,16 @@ public final Builder filter(Function<Query.Builder, ObjectBuilder<Query>> fn) {
return filter(fn.apply(new Query.Builder()).build());
}

/**
* The minimum similarity for a vector to be considered a match
* <p>
* API name: {@code similarity}
*/
public final Builder similarity(@Nullable Float value) {
this.similarity = value;
return this;
}

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -392,6 +424,7 @@ protected static void setupKnnQueryDeserializer(ObjectDeserializer<KnnQuery.Buil
op.add(Builder::numCandidates, JsonpDeserializer.longDeserializer(), "num_candidates");
op.add(Builder::boost, JsonpDeserializer.floatDeserializer(), "boost");
op.add(Builder::filter, JsonpDeserializer.arrayDeserializer(Query._DESERIALIZER), "filter");
op.add(Builder::similarity, JsonpDeserializer.floatDeserializer(), "similarity");

}

Expand Down
Loading

0 comments on commit 4b2b4f8

Please sign in to comment.