Skip to content

Commit

Permalink
Generate ListDanglingIndicesResponse
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Aug 2, 2024
1 parent 61e0fac commit 2580454
Showing 1 changed file with 88 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,24 @@
* GitHub history for details.
*/

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

package org.opensearch.client.opensearch.dangling_indices;

import jakarta.json.stream.JsonGenerator;
import java.util.List;
import java.util.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch._types.NodeStatistics;
import org.opensearch.client.opensearch.dangling_indices.list_dangling_indices.DanglingIndex;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;
Expand All @@ -49,47 +56,82 @@
// typedef: dangling_indices.list_dangling_indices.Response

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class ListDanglingIndicesResponse implements PlainJsonSerializable {

@Nullable
private final String clusterName;

private final List<DanglingIndex> danglingIndices;

@Nullable
private final NodeStatistics nodes;

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

private ListDanglingIndicesResponse(Builder builder) {

this.clusterName = builder.clusterName;
this.danglingIndices = ApiTypeHelper.unmodifiableRequired(builder.danglingIndices, this, "danglingIndices");

this.nodes = builder.nodes;
}

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

/**
* API name: {@code cluster_name}
*/
@Nullable
public final String clusterName() {
return this.clusterName;
}

/**
* Required - API name: {@code dangling_indices}
*/
public final List<DanglingIndex> danglingIndices() {
return this.danglingIndices;
}

/**
* API name: {@code _nodes}
*/
@Nullable
public final NodeStatistics nodes() {
return this.nodes;
}

/**
* Serialize this object to JSON.
*/
@Override
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
if (this.clusterName != null) {
generator.writeKey("cluster_name");
generator.write(this.clusterName);

}

if (ApiTypeHelper.isDefined(this.danglingIndices)) {
generator.writeKey("dangling_indices");
generator.writeStartArray();
for (DanglingIndex item0 : this.danglingIndices) {
item0.serialize(generator, mapper);
generator.writeKey("dangling_indices");
generator.writeStartArray();
for (DanglingIndex item0 : this.danglingIndices) {
item0.serialize(generator, mapper);

}
generator.writeEnd();
}
generator.writeEnd();

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

}

Expand All @@ -100,14 +142,27 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
/**
* Builder for {@link ListDanglingIndicesResponse}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<ListDanglingIndicesResponse> {
@Nullable
private String clusterName;
private List<DanglingIndex> danglingIndices;
@Nullable
private NodeStatistics nodes;

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

/**
* Required - API name: {@code dangling_indices}
*
* <p>
* Adds all elements of <code>list</code> to <code>danglingIndices</code>.
* </p>
*/
public final Builder danglingIndices(List<DanglingIndex> list) {
this.danglingIndices = _listAddAll(this.danglingIndices, list);
Expand All @@ -116,8 +171,10 @@ public final Builder danglingIndices(List<DanglingIndex> list) {

/**
* Required - API name: {@code dangling_indices}
*
* <p>
* Adds one or more values to <code>danglingIndices</code>.
* </p>
*/
public final Builder danglingIndices(DanglingIndex value, DanglingIndex... values) {
this.danglingIndices = _listAdd(this.danglingIndices, value, values);
Expand All @@ -126,26 +183,41 @@ public final Builder danglingIndices(DanglingIndex value, DanglingIndex... value

/**
* Required - API name: {@code dangling_indices}
*
* <p>
* Adds a value to <code>danglingIndices</code> using a builder lambda.
* </p>
*/
public final Builder danglingIndices(Function<DanglingIndex.Builder, ObjectBuilder<DanglingIndex>> fn) {
return danglingIndices(fn.apply(new DanglingIndex.Builder()).build());
}

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

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

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

return new ListDanglingIndicesResponse(this);
}
}

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

/**
Expand All @@ -157,9 +229,8 @@ public ListDanglingIndicesResponse build() {
);

protected static void setupListDanglingIndicesResponseDeserializer(ObjectDeserializer<ListDanglingIndicesResponse.Builder> op) {

op.add(Builder::clusterName, JsonpDeserializer.stringDeserializer(), "cluster_name");
op.add(Builder::danglingIndices, JsonpDeserializer.arrayDeserializer(DanglingIndex._DESERIALIZER), "dangling_indices");

op.add(Builder::nodes, NodeStatistics._DESERIALIZER, "_nodes");
}

}

0 comments on commit 2580454

Please sign in to comment.