Skip to content

Commit

Permalink
[codegen] update to latest api spec
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta committed Jul 11, 2024
1 parent 9e274d5 commit a0272da
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public class GeoDistanceSort implements SortOptionsVariant, JsonpSerializable {
@Nullable
private final DistanceUnit unit;

@Nullable
private final NestedSortValue nested;

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

private GeoDistanceSort(Builder builder) {
Expand All @@ -92,6 +95,7 @@ private GeoDistanceSort(Builder builder) {
this.ignoreUnmapped = builder.ignoreUnmapped;
this.order = builder.order;
this.unit = builder.unit;
this.nested = builder.nested;

}

Expand Down Expand Up @@ -161,6 +165,14 @@ public final DistanceUnit unit() {
return this.unit;
}

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

/**
* Serialize this object to JSON.
*/
Expand Down Expand Up @@ -200,6 +212,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("unit");
this.unit.serialize(generator, mapper);
}
if (this.nested != null) {
generator.writeKey("nested");
this.nested.serialize(generator, mapper);

}

}

Expand Down Expand Up @@ -265,6 +282,9 @@ public final Builder location(Function<GeoLocation.Builder, ObjectBuilder<GeoLoc
@Nullable
private DistanceUnit unit;

@Nullable
private NestedSortValue nested;

/**
* API name: {@code mode}
*/
Expand Down Expand Up @@ -305,6 +325,21 @@ public final Builder unit(@Nullable DistanceUnit value) {
return this;
}

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

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

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -338,6 +373,7 @@ protected static void setupGeoDistanceSortDeserializer(ObjectDeserializer<GeoDis
op.add(Builder::ignoreUnmapped, JsonpDeserializer.booleanDeserializer(), "ignore_unmapped");
op.add(Builder::order, SortOrder._DESERIALIZER, "order");
op.add(Builder::unit, DistanceUnit._DESERIALIZER, "unit");
op.add(Builder::nested, NestedSortValue._DESERIALIZER, "nested");

op.setUnknownFieldHandler((builder, name, parser, mapper) -> {
builder.field(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
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.util.Objects;
Expand Down Expand Up @@ -56,14 +55,15 @@
*/
@JsonpDeserializable
public class SnowballTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant {
@Nullable
private final SnowballLanguage language;

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

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

this.language = ApiTypeHelper.requireNonNull(builder.language, this, "language");
this.language = builder.language;

}

Expand All @@ -80,8 +80,9 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() {
}

/**
* Required - API name: {@code language}
* API name: {@code language}
*/
@Nullable
public final SnowballLanguage language() {
return this.language;
}
Expand All @@ -90,8 +91,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.write("type", "snowball");
super.serializeInternal(generator, mapper);
generator.writeKey("language");
this.language.serialize(generator, mapper);
if (this.language != null) {
generator.writeKey("language");
this.language.serialize(generator, mapper);
}

}

Expand All @@ -104,12 +107,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
public static class Builder extends TokenFilterBase.AbstractBuilder<Builder>
implements
ObjectBuilder<SnowballTokenFilter> {
@Nullable
private SnowballLanguage language;

/**
* Required - API name: {@code language}
* API name: {@code language}
*/
public final Builder language(SnowballLanguage value) {
public final Builder language(@Nullable SnowballLanguage value) {
this.language = value;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import co.elastic.clients.util.ObjectBuilder;
import co.elastic.clients.util.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.Integer;
import java.lang.Long;
import java.util.Objects;
import java.util.function.Function;
Expand Down Expand Up @@ -65,12 +66,15 @@ public class IlmIndicatorDetails implements JsonpSerializable {

private final long policies;

private final int stagnatingIndices;

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

private IlmIndicatorDetails(Builder builder) {

this.ilmStatus = ApiTypeHelper.requireNonNull(builder.ilmStatus, this, "ilmStatus");
this.policies = ApiTypeHelper.requireNonNull(builder.policies, this, "policies");
this.stagnatingIndices = ApiTypeHelper.requireNonNull(builder.stagnatingIndices, this, "stagnatingIndices");

}

Expand All @@ -92,6 +96,13 @@ public final long policies() {
return this.policies;
}

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

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

generator.writeKey("stagnating_indices");
generator.write(this.stagnatingIndices);

}

@Override
Expand All @@ -128,6 +142,8 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder>

private Long policies;

private Integer stagnatingIndices;

/**
* Required - API name: {@code ilm_status}
*/
Expand All @@ -144,6 +160,14 @@ public final Builder policies(long value) {
return this;
}

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

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -174,6 +198,7 @@ protected static void setupIlmIndicatorDetailsDeserializer(ObjectDeserializer<Il

op.add(Builder::ilmStatus, LifecycleOperationMode._DESERIALIZER, "ilm_status");
op.add(Builder::policies, JsonpDeserializer.longDeserializer(), "policies");
op.add(Builder::stagnatingIndices, JsonpDeserializer.integerDeserializer(), "stagnating_indices");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
public class ShardsAvailabilityIndicatorDetails implements JsonpSerializable {
private final long creatingPrimaries;

private final long creatingReplicas;

private final long initializingPrimaries;

private final long initializingReplicas;
Expand All @@ -82,6 +84,7 @@ public class ShardsAvailabilityIndicatorDetails implements JsonpSerializable {
private ShardsAvailabilityIndicatorDetails(Builder builder) {

this.creatingPrimaries = ApiTypeHelper.requireNonNull(builder.creatingPrimaries, this, "creatingPrimaries");
this.creatingReplicas = ApiTypeHelper.requireNonNull(builder.creatingReplicas, this, "creatingReplicas");
this.initializingPrimaries = ApiTypeHelper.requireNonNull(builder.initializingPrimaries, this,
"initializingPrimaries");
this.initializingReplicas = ApiTypeHelper.requireNonNull(builder.initializingReplicas, this,
Expand Down Expand Up @@ -109,6 +112,13 @@ public final long creatingPrimaries() {
return this.creatingPrimaries;
}

/**
* Required - API name: {@code creating_replicas}
*/
public final long creatingReplicas() {
return this.creatingReplicas;
}

/**
* Required - API name: {@code initializing_primaries}
*/
Expand Down Expand Up @@ -179,6 +189,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("creating_primaries");
generator.write(this.creatingPrimaries);

generator.writeKey("creating_replicas");
generator.write(this.creatingReplicas);

generator.writeKey("initializing_primaries");
generator.write(this.initializingPrimaries);

Expand Down Expand Up @@ -221,6 +234,8 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder>
ObjectBuilder<ShardsAvailabilityIndicatorDetails> {
private Long creatingPrimaries;

private Long creatingReplicas;

private Long initializingPrimaries;

private Long initializingReplicas;
Expand All @@ -245,6 +260,14 @@ public final Builder creatingPrimaries(long value) {
return this;
}

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

/**
* Required - API name: {@code initializing_primaries}
*/
Expand Down Expand Up @@ -340,6 +363,7 @@ protected static void setupShardsAvailabilityIndicatorDetailsDeserializer(
ObjectDeserializer<ShardsAvailabilityIndicatorDetails.Builder> op) {

op.add(Builder::creatingPrimaries, JsonpDeserializer.longDeserializer(), "creating_primaries");
op.add(Builder::creatingReplicas, JsonpDeserializer.longDeserializer(), "creating_replicas");
op.add(Builder::initializingPrimaries, JsonpDeserializer.longDeserializer(), "initializing_primaries");
op.add(Builder::initializingReplicas, JsonpDeserializer.longDeserializer(), "initializing_replicas");
op.add(Builder::restartingPrimaries, JsonpDeserializer.longDeserializer(), "restarting_primaries");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class SlmIndicatorDetails implements JsonpSerializable {

private final long policies;

@Nullable
private final SlmIndicatorUnhealthyPolicies unhealthyPolicies;

// ---------------------------------------------------------------------------------------------
Expand All @@ -73,7 +74,7 @@ private SlmIndicatorDetails(Builder builder) {

this.slmStatus = ApiTypeHelper.requireNonNull(builder.slmStatus, this, "slmStatus");
this.policies = ApiTypeHelper.requireNonNull(builder.policies, this, "policies");
this.unhealthyPolicies = ApiTypeHelper.requireNonNull(builder.unhealthyPolicies, this, "unhealthyPolicies");
this.unhealthyPolicies = builder.unhealthyPolicies;

}

Expand All @@ -96,8 +97,9 @@ public final long policies() {
}

/**
* Required - API name: {@code unhealthy_policies}
* API name: {@code unhealthy_policies}
*/
@Nullable
public final SlmIndicatorUnhealthyPolicies unhealthyPolicies() {
return this.unhealthyPolicies;
}
Expand All @@ -118,8 +120,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("policies");
generator.write(this.policies);

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

}

}

Expand All @@ -141,6 +146,7 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder>

private Long policies;

@Nullable
private SlmIndicatorUnhealthyPolicies unhealthyPolicies;

/**
Expand All @@ -160,15 +166,15 @@ public final Builder policies(long value) {
}

/**
* Required - API name: {@code unhealthy_policies}
* API name: {@code unhealthy_policies}
*/
public final Builder unhealthyPolicies(SlmIndicatorUnhealthyPolicies value) {
public final Builder unhealthyPolicies(@Nullable SlmIndicatorUnhealthyPolicies value) {
this.unhealthyPolicies = value;
return this;
}

/**
* Required - API name: {@code unhealthy_policies}
* API name: {@code unhealthy_policies}
*/
public final Builder unhealthyPolicies(
Function<SlmIndicatorUnhealthyPolicies.Builder, ObjectBuilder<SlmIndicatorUnhealthyPolicies>> fn) {
Expand Down
Loading

0 comments on commit a0272da

Please sign in to comment.