Skip to content

Commit

Permalink
Generate indices.create
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Oct 31, 2024
1 parent 98d2b4b commit d858835
Show file tree
Hide file tree
Showing 13 changed files with 327 additions and 322 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,24 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types;

import javax.annotation.Generated;
import org.opensearch.client.json.JsonEnum;
import org.opensearch.client.json.JsonpDeserializable;

// typedef: _types.WaitForActiveShardOptions

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public enum WaitForActiveShardOptions implements JsonEnum {
All("all"),

;
IndexSetting("index-setting");

private final String jsonValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types;

import jakarta.json.stream.JsonGenerator;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Generated;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.JsonpSerializable;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.UnionDeserializer;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;
Expand All @@ -48,12 +55,14 @@
// typedef: _types.WaitForActiveShards

@JsonpDeserializable
public class WaitForActiveShards implements TaggedUnion<WaitForActiveShards.Kind, Object>, JsonpSerializable {

@Generated("org.opensearch.client.codegen.CodeGenerator")
public class WaitForActiveShards implements TaggedUnion<WaitForActiveShards.Kind, Object>, PlainJsonSerializable {
/**
* {@link WaitForActiveShards} variant kinds.
*/
public enum Kind {
Option,
Count

Count,
Option
}

private final Kind _kind;
Expand All @@ -74,27 +83,40 @@ private WaitForActiveShards(Kind kind, Object value) {
this._value = value;
}

private WaitForActiveShards(Builder builder) {
this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
this._value = ApiTypeHelper.requireNonNull(builder._value, builder, "<variant value>");
}

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

public String _toJsonString() {
switch (_kind) {
case Option:
return this.option().jsonValue();
case Count:
return String.valueOf(this.count());

case Option:
return this.option().jsonValue();
default:
throw new IllegalStateException("Unknown kind " + _kind);
}
}

private WaitForActiveShards(Builder builder) {

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

/**
* Is this variant instance of kind {@code count}?
*/
public boolean isCount() {
return _kind == Kind.Count;
}

public static WaitForActiveShards of(Function<Builder, ObjectBuilder<WaitForActiveShards>> fn) {
return fn.apply(new Builder()).build();
/**
* Get the {@code count} variant value.
*
* @throws IllegalStateException if the current variant is not the {@code count} kind.
*/
public Integer count() {
return TaggedUnionUtils.get(this, Kind.Count);
}

/**
Expand All @@ -107,30 +129,12 @@ public boolean isOption() {
/**
* Get the {@code option} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code option} kind.
* @throws IllegalStateException if the current variant is not the {@code option} kind.
*/
public WaitForActiveShardOptions option() {
return TaggedUnionUtils.get(this, Kind.Option);
}

/**
* Is this variant instance of kind {@code count}?
*/
public boolean isCount() {
return _kind == Kind.Count;
}

/**
* Get the {@code count} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code count} kind.
*/
public Integer count() {
return TaggedUnionUtils.get(this, Kind.Count);
}

@Override
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
if (_value instanceof JsonpSerializable) {
Expand All @@ -139,44 +143,58 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
switch (_kind) {
case Count:
generator.write(((Integer) this._value));

break;
}
}

}

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

public ObjectBuilder<WaitForActiveShards> option(WaitForActiveShardOptions v) {
this._kind = Kind.Option;
public ObjectBuilder<WaitForActiveShards> count(Integer v) {
this._kind = Kind.Count;
this._value = v;
return this;
}

public ObjectBuilder<WaitForActiveShards> count(Integer v) {
this._kind = Kind.Count;
public ObjectBuilder<WaitForActiveShards> option(WaitForActiveShardOptions v) {
this._kind = Kind.Option;
this._value = v;
return this;
}

@Override
public WaitForActiveShards build() {
_checkSingleUse();
return new WaitForActiveShards(this);
}

}

private static JsonpDeserializer<WaitForActiveShards> buildWaitForActiveShardsDeserializer() {
return new UnionDeserializer.Builder<WaitForActiveShards, Kind, Object>(WaitForActiveShards::new, false).addMember(
Kind.Option,
WaitForActiveShardOptions._DESERIALIZER
).addMember(Kind.Count, JsonpDeserializer.integerDeserializer()).build();
Kind.Count,
JsonpDeserializer.integerDeserializer()
).addMember(Kind.Option, WaitForActiveShardOptions._DESERIALIZER).build();
}

public static final JsonpDeserializer<WaitForActiveShards> _DESERIALIZER = JsonpDeserializer.lazy(
WaitForActiveShards::buildWaitForActiveShardsDeserializer
);

@Override
public int hashCode() {
int result = 17;
result = 31 * result + Objects.hashCode(this._kind);
result = 31 * result + Objects.hashCode(this._value);
return result;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
WaitForActiveShards other = (WaitForActiveShards) o;
return Objects.equals(this._kind, other._kind) && Objects.equals(this._value, other._value);
}
}
Loading

0 comments on commit d858835

Please sign in to comment.