Skip to content

Commit

Permalink
[codegen] Update to latest API specification
Browse files Browse the repository at this point in the history
  • Loading branch information
swallez committed Jan 24, 2022
1 parent f7f03a8 commit 7444423
Show file tree
Hide file tree
Showing 155 changed files with 12,266 additions and 8,645 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package co.elastic.clients.elasticsearch.indices.rollover;
package co.elastic.clients.elasticsearch._types;

import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
Expand All @@ -36,26 +35,25 @@
import co.elastic.clients.util.TaggedUnion;
import co.elastic.clients.util.TaggedUnionUtils;
import jakarta.json.stream.JsonGenerator;
import java.lang.Long;
import java.lang.Object;
import java.lang.String;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

// typedef: indices.rollover.IndexRolloverMapping
// typedef: _types.DateOrEpochMillis

/**
*
* @see <a href=
* "../../doc-files/api-spec.html#indices.rollover.IndexRolloverMapping">API
* @see <a href="../doc-files/api-spec.html#_types.DateOrEpochMillis">API
* specification</a>
*/
@JsonpDeserializable
public class IndexRolloverMapping implements TaggedUnion<IndexRolloverMapping.Kind, Object>, JsonpSerializable {
public class DateOrEpochMillis implements TaggedUnion<DateOrEpochMillis.Kind, Object>, JsonpSerializable {

public enum Kind {
ByType, Single
Date, Millis

}

Expand All @@ -72,54 +70,66 @@ public final Object _get() {
return _value;
}

private IndexRolloverMapping(Kind kind, Object value) {
private DateOrEpochMillis(Kind kind, Object value) {
this._kind = kind;
this._value = value;
}

private IndexRolloverMapping(Builder builder) {
public String _toJsonString() {
switch (_kind) {
case Date :
return this.date();
case Millis :
return String.valueOf(this.millis());

default :
throw new IllegalStateException("Unknown kind " + _kind);
}
}

private DateOrEpochMillis(Builder builder) {

this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
this._value = ApiTypeHelper.requireNonNull(builder._value, builder, "<variant value>");

}

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

/**
* Is this variant instance of kind {@code by_type}?
* Is this variant instance of kind {@code date}?
*/
public boolean isByType() {
return _kind == Kind.ByType;
public boolean isDate() {
return _kind == Kind.Date;
}

/**
* Get the {@code by_type} variant value.
* Get the {@code date} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code by_type} kind.
* if the current variant is not of the {@code date} kind.
*/
public Map<String, TypeMapping> byType() {
return TaggedUnionUtils.get(this, Kind.ByType);
public String date() {
return TaggedUnionUtils.get(this, Kind.Date);
}

/**
* Is this variant instance of kind {@code single}?
* Is this variant instance of kind {@code millis}?
*/
public boolean isSingle() {
return _kind == Kind.Single;
public boolean isMillis() {
return _kind == Kind.Millis;
}

/**
* Get the {@code single} variant value.
* Get the {@code millis} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code single} kind.
* if the current variant is not of the {@code millis} kind.
*/
public TypeMapping single() {
return TaggedUnionUtils.get(this, Kind.Single);
public Long millis() {
return TaggedUnionUtils.get(this, Kind.Millis);
}

@Override
Expand All @@ -128,55 +138,48 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
((JsonpSerializable) _value).serialize(generator, mapper);
} else {
switch (_kind) {
case ByType :
generator.writeStartObject();
for (Map.Entry<String, TypeMapping> item0 : ((Map<String, TypeMapping>) this._value).entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);
case Date :
generator.write(((String) this._value));

}
generator.writeEnd();
break;
case Millis :
generator.write(((Long) this._value));

break;
}
}

}

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<IndexRolloverMapping> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<DateOrEpochMillis> {
private Kind _kind;
private Object _value;

public ObjectBuilder<IndexRolloverMapping> byType(Map<String, TypeMapping> v) {
this._kind = Kind.ByType;
public ObjectBuilder<DateOrEpochMillis> date(String v) {
this._kind = Kind.Date;
this._value = v;
return this;
}

public ObjectBuilder<IndexRolloverMapping> single(TypeMapping v) {
this._kind = Kind.Single;
public ObjectBuilder<DateOrEpochMillis> millis(Long v) {
this._kind = Kind.Millis;
this._value = v;
return this;
}

public ObjectBuilder<IndexRolloverMapping> single(
Function<TypeMapping.Builder, ObjectBuilder<TypeMapping>> fn) {
return this.single(fn.apply(new TypeMapping.Builder()).build());
}

public IndexRolloverMapping build() {
public DateOrEpochMillis build() {
_checkSingleUse();
return new IndexRolloverMapping(this);
return new DateOrEpochMillis(this);
}

}

private static JsonpDeserializer<IndexRolloverMapping> buildIndexRolloverMappingDeserializer() {
return new UnionDeserializer.Builder<IndexRolloverMapping, Kind, Object>(IndexRolloverMapping::new, false)
.addMember(Kind.ByType, JsonpDeserializer.stringMapDeserializer(TypeMapping._DESERIALIZER))
.addMember(Kind.Single, TypeMapping._DESERIALIZER).build();
private static JsonpDeserializer<DateOrEpochMillis> buildDateOrEpochMillisDeserializer() {
return new UnionDeserializer.Builder<DateOrEpochMillis, Kind, Object>(DateOrEpochMillis::new, false)
.addMember(Kind.Date, JsonpDeserializer.stringDeserializer())
.addMember(Kind.Millis, JsonpDeserializer.longDeserializer()).build();
}

public static final JsonpDeserializer<IndexRolloverMapping> _DESERIALIZER = JsonpDeserializer
.lazy(IndexRolloverMapping::buildIndexRolloverMappingDeserializer);
public static final JsonpDeserializer<DateOrEpochMillis> _DESERIALIZER = JsonpDeserializer
.lazy(DateOrEpochMillis::buildDateOrEpochMillisDeserializer);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,18 @@
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package co.elastic.clients.elasticsearch.indices.rollover;

import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
import java.lang.String;
package co.elastic.clients.elasticsearch._types;

/**
* Builders for {@link IndexRolloverMapping} variants.
* Builders for {@link DateOrEpochMillis} variants.
* <p>
* Variants <code>by_type</code> are not available here as they don't have a
* dedicated class. Use {@link IndexRolloverMapping}'s builder for these.
* Variants <code>date</code>, <code>millis</code> are not available here as
* they don't have a dedicated class. Use {@link DateOrEpochMillis}'s builder
* for these.
*
*/
public class IndexRolloverMappingBuilders {
private IndexRolloverMappingBuilders() {
}

/**
* Creates a builder for the {@link TypeMapping single}
* {@code IndexRolloverMapping} variant.
*/
public static TypeMapping.Builder single() {
return new TypeMapping.Builder();
public class DateOrEpochMillisBuilders {
private DateOrEpochMillisBuilders() {
}

}

This file was deleted.

Loading

0 comments on commit 7444423

Please sign in to comment.