Skip to content

Commit

Permalink
Generate DanglingIndex
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 501bb2c commit 61e0fac
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@
* GitHub history for details.
*/

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

package org.opensearch.client.opensearch.dangling_indices.list_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;
Expand All @@ -48,30 +54,49 @@
// typedef: dangling_indices.list_dangling_indices.DanglingIndex

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

@Nullable
private final String creationDate;

private final long creationDateMillis;

private final String indexName;

private final String indexUuid;

private final String creationDateMillis;

private final List<String> nodeIds;

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

private DanglingIndex(Builder builder) {

this.creationDate = builder.creationDate;
this.creationDateMillis = ApiTypeHelper.requireNonNull(builder.creationDateMillis, this, "creationDateMillis");
this.indexName = ApiTypeHelper.requireNonNull(builder.indexName, this, "indexName");
this.indexUuid = ApiTypeHelper.requireNonNull(builder.indexUuid, this, "indexUuid");
this.creationDateMillis = ApiTypeHelper.requireNonNull(builder.creationDateMillis, this, "creationDateMillis");
this.nodeIds = ApiTypeHelper.unmodifiableRequired(builder.nodeIds, this, "nodeIds");

}

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

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

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

/**
* Required - API name: {@code index_name}
*/
Expand All @@ -86,13 +111,6 @@ public final String indexUuid() {
return this.indexUuid;
}

/**
* Required - API name: {@code creation_date_millis}
*/
public final String creationDateMillis() {
return this.creationDateMillis;
}

/**
* Required - API name: {@code node_ids}
*/
Expand All @@ -103,33 +121,36 @@ public final List<String> nodeIds() {
/**
* 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.creationDate != null) {
generator.writeKey("creation_date");
generator.write(this.creationDate);

}

generator.writeKey("creation_date_millis");
generator.write(this.creationDateMillis);

generator.writeKey("index_name");
generator.write(this.indexName);

generator.writeKey("index_uuid");
generator.write(this.indexUuid);

generator.writeKey("creation_date_millis");
generator.write(this.creationDateMillis);

if (ApiTypeHelper.isDefined(this.nodeIds)) {
generator.writeKey("node_ids");
generator.writeStartArray();
for (String item0 : this.nodeIds) {
generator.write(item0);

}
generator.writeEnd();
generator.writeKey("node_ids");
generator.writeStartArray();
for (String item0 : this.nodeIds) {
generator.write(item0);

}
generator.writeEnd();

}

Expand All @@ -138,15 +159,29 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
/**
* Builder for {@link DanglingIndex}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<DanglingIndex> {
@Nullable
private String creationDate;
private Long creationDateMillis;
private String indexName;

private String indexUuid;
private List<String> nodeIds;

private String creationDateMillis;
/**
* API name: {@code creation_date}
*/
public final Builder creationDate(@Nullable String value) {
this.creationDate = value;
return this;
}

private List<String> nodeIds;
/**
* Required - API name: {@code creation_date_millis}
*/
public final Builder creationDateMillis(long value) {
this.creationDateMillis = value;
return this;
}

/**
* Required - API name: {@code index_name}
Expand All @@ -164,18 +199,12 @@ public final Builder indexUuid(String value) {
return this;
}

/**
* Required - API name: {@code creation_date_millis}
*/
public final Builder creationDateMillis(String value) {
this.creationDateMillis = value;
return this;
}

/**
* Required - API name: {@code node_ids}
*
* <p>
* Adds all elements of <code>list</code> to <code>nodeIds</code>.
* </p>
*/
public final Builder nodeIds(List<String> list) {
this.nodeIds = _listAddAll(this.nodeIds, list);
Expand All @@ -184,8 +213,10 @@ public final Builder nodeIds(List<String> list) {

/**
* Required - API name: {@code node_ids}
*
* <p>
* Adds one or more values to <code>nodeIds</code>.
* </p>
*/
public final Builder nodeIds(String value, String... values) {
this.nodeIds = _listAdd(this.nodeIds, value, values);
Expand All @@ -195,16 +226,14 @@ public final Builder nodeIds(String value, String... values) {
/**
* Builds a {@link DanglingIndex}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
public DanglingIndex build() {
_checkSingleUse();

return new DanglingIndex(this);
}
}

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

/**
Expand All @@ -216,12 +245,10 @@ public DanglingIndex build() {
);

protected static void setupDanglingIndexDeserializer(ObjectDeserializer<DanglingIndex.Builder> op) {

op.add(Builder::creationDate, JsonpDeserializer.stringDeserializer(), "creation_date");
op.add(Builder::creationDateMillis, JsonpDeserializer.longDeserializer(), "creation_date_millis");
op.add(Builder::indexName, JsonpDeserializer.stringDeserializer(), "index_name");
op.add(Builder::indexUuid, JsonpDeserializer.stringDeserializer(), "index_uuid");
op.add(Builder::creationDateMillis, JsonpDeserializer.stringDeserializer(), "creation_date_millis");
op.add(Builder::nodeIds, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "node_ids");

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,15 @@ private void visitInto(OpenApiSchema schema, ObjectShape shape) {
)
);

var additionalProperties = schema.getAdditionalProperties();
if (additionalProperties.isPresent()) {
var valueType = mapType(additionalProperties.get());
var additionalProperties = schema.getAdditionalProperties().orElse(null);
if (additionalProperties != null) {
var valueType = mapType(additionalProperties);
shape.setAdditionalPropertiesField(
new Field(
"metadata",
additionalProperties.getTitle().orElseThrow(),
Types.Java.Util.Map(Types.Java.Lang.String, valueType),
false,
additionalProperties.get().getDescription().orElse(null),
additionalProperties.getDescription().orElse(null),
null,
true
)
Expand Down

0 comments on commit 61e0fac

Please sign in to comment.