Skip to content

Commit

Permalink
Fixes from spec 2704 (#844)
Browse files Browse the repository at this point in the history
* [codegen] update to latest api spec

* fixed + new unit tests

* code style
  • Loading branch information
l-trotta committed Jul 12, 2024
1 parent 12b7ab5 commit c605efa
Show file tree
Hide file tree
Showing 75 changed files with 10,432 additions and 1,436 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 @@ -21,6 +21,10 @@

import co.elastic.clients.elasticsearch.security.query_api_keys.ApiKeyQuery;
import co.elastic.clients.elasticsearch.security.query_api_keys.ApiKeyQueryVariant;
import co.elastic.clients.elasticsearch.security.query_role.RoleQuery;
import co.elastic.clients.elasticsearch.security.query_role.RoleQueryVariant;
import co.elastic.clients.elasticsearch.security.query_user.UserQuery;
import co.elastic.clients.elasticsearch.security.query_user.UserQueryVariant;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
Expand Down Expand Up @@ -58,7 +62,12 @@
* specification</a>
*/
@JsonpDeserializable
public class BoolQuery extends QueryBase implements ApiKeyQueryVariant, QueryVariant {
public class BoolQuery extends QueryBase
implements
ApiKeyQueryVariant,
QueryVariant,
RoleQueryVariant,
UserQueryVariant {
private final List<Query> filter;

@Nullable
Expand Down Expand Up @@ -103,6 +112,22 @@ public Query.Kind _queryKind() {
return Query.Kind.Bool;
}

/**
* RoleQuery variant kind.
*/
@Override
public RoleQuery.Kind _roleQueryKind() {
return RoleQuery.Kind.Bool;
}

/**
* UserQuery variant kind.
*/
@Override
public UserQuery.Kind _userQueryKind() {
return UserQuery.Kind.Bool;
}

/**
* The clause (query) must appear in matching documents. However, unlike
* <code>must</code>, the score of the query will be ignored.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

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

import co.elastic.clients.elasticsearch._types.Time;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.String;
import java.util.Objects;
import java.util.function.Function;

//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------------------
//
// This code is generated from the Elasticsearch API specification
// at https://github.com/elastic/elasticsearch-specification
//
// Manual updates to this file will be lost when the code is
// re-generated.
//
// If you find a property that is missing or wrongly typed, please
// open an issue or a PR on the API specification repository.
//
//----------------------------------------------------------------

// typedef: _types.query_dsl.DateDecayFunction

/**
*
* @see <a href=
* "../../doc-files/api-spec.html#_types.query_dsl.DateDecayFunction">API
* specification</a>
*/
@JsonpDeserializable
public class DateDecayFunction extends DecayFunctionBase<String, Time> implements DecayFunctionVariant {
// ---------------------------------------------------------------------------------------------

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

}

public static DateDecayFunction of(Function<Builder, ObjectBuilder<DateDecayFunction>> fn) {
return fn.apply(new Builder()).build();
}

/**
* DecayFunction variant kind.
*/
@Override
public DecayFunction.Kind _decayFunctionKind() {
return DecayFunction.Kind.Date;
}

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

/**
* Builder for {@link DateDecayFunction}.
*/

public static class Builder extends DecayFunctionBase.AbstractBuilder<String, Time, Builder>
implements
ObjectBuilder<DateDecayFunction> {
@Override
protected Builder self() {
return this;
}

/**
* Builds a {@link DateDecayFunction}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public DateDecayFunction build() {
_checkSingleUse();
super.tOriginSerializer(null);
super.tScaleSerializer(null);

return new DateDecayFunction(this);
}
}

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

/**
* Json deserializer for {@link DateDecayFunction}
*/
public static final JsonpDeserializer<DateDecayFunction> _DESERIALIZER = ObjectBuilderDeserializer
.lazy(Builder::new, DateDecayFunction::setupDateDecayFunctionDeserializer);

protected static void setupDateDecayFunctionDeserializer(ObjectDeserializer<DateDecayFunction.Builder> op) {
DecayFunctionBase.setupDecayFunctionBaseDeserializer(op, JsonpDeserializer.stringDeserializer(),
Time._DESERIALIZER);

}

}
Loading

0 comments on commit c605efa

Please sign in to comment.