Skip to content

Commit

Permalink
Generate indices.add_block
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Dec 15, 2024
1 parent 44928cd commit 26f63d2
Show file tree
Hide file tree
Showing 10 changed files with 461 additions and 260 deletions.

Large diffs are not rendered by default.

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.indices;

import jakarta.json.stream.JsonGenerator;
import java.util.List;
import java.util.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
Expand All @@ -43,122 +49,163 @@
import org.opensearch.client.opensearch._types.AcknowledgedResponseBase;
import org.opensearch.client.opensearch.indices.add_block.IndicesBlockStatus;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.CopyableBuilder;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ToCopyableBuilder;

// typedef: indices.add_block.Response

@JsonpDeserializable
public class AddBlockResponse extends AcknowledgedResponseBase {
private final boolean shardsAcknowledged;
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class AddBlockResponse extends AcknowledgedResponseBase implements ToCopyableBuilder<AddBlockResponse.Builder, AddBlockResponse> {

@Nonnull
private final List<IndicesBlockStatus> indices;

private final boolean shardsAcknowledged;

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

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

this.shardsAcknowledged = ApiTypeHelper.requireNonNull(builder.shardsAcknowledged, this, "shardsAcknowledged");
this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices");

this.shardsAcknowledged = ApiTypeHelper.requireNonNull(builder.shardsAcknowledged, this, "shardsAcknowledged");
}

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

/**
* Required - API name: {@code shards_acknowledged}
* Required - API name: {@code indices}
*/
public final boolean shardsAcknowledged() {
return this.shardsAcknowledged;
@Nonnull
public final List<IndicesBlockStatus> indices() {
return this.indices;
}

/**
* Required - API name: {@code indices}
* Required - API name: {@code shards_acknowledged}
*/
public final List<IndicesBlockStatus> indices() {
return this.indices;
public final boolean shardsAcknowledged() {
return this.shardsAcknowledged;
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
generator.writeKey("indices");
generator.writeStartArray();
for (IndicesBlockStatus item0 : this.indices) {
item0.serialize(generator, mapper);
}
generator.writeEnd();

generator.writeKey("shards_acknowledged");
generator.write(this.shardsAcknowledged);
}

if (ApiTypeHelper.isDefined(this.indices)) {
generator.writeKey("indices");
generator.writeStartArray();
for (IndicesBlockStatus item0 : this.indices) {
item0.serialize(generator, mapper);

}
generator.writeEnd();

}
// ---------------------------------------------------------------------------------------------

@Override
@Nonnull
public Builder toBuilder() {
return new Builder(this);
}

// ---------------------------------------------------------------------------------------------
@Nonnull
public static Builder builder() {
return new Builder();
}

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

public static class Builder extends AcknowledgedResponseBase.AbstractBuilder<Builder> implements ObjectBuilder<AddBlockResponse> {
public static class Builder extends AcknowledgedResponseBase.AbstractBuilder<Builder>
implements
CopyableBuilder<Builder, AddBlockResponse> {
private List<IndicesBlockStatus> indices;
private Boolean shardsAcknowledged;

private List<IndicesBlockStatus> indices;
public Builder() {}

/**
* Required - API name: {@code shards_acknowledged}
*/
public final Builder shardsAcknowledged(boolean value) {
this.shardsAcknowledged = value;
private Builder(AddBlockResponse o) {
super(o);
this.indices = _listCopy(o.indices);
this.shardsAcknowledged = o.shardsAcknowledged;
}

private Builder(Builder o) {
super(o);
this.indices = _listCopy(o.indices);
this.shardsAcknowledged = o.shardsAcknowledged;
}

@Override
@Nonnull
public Builder copy() {
return new Builder(this);
}

@Override
@Nonnull
protected Builder self() {
return this;
}

/**
* Required - API name: {@code indices}
*
* <p>
* Adds all elements of <code>list</code> to <code>indices</code>.
* </p>
*/
@Nonnull
public final Builder indices(List<IndicesBlockStatus> list) {
this.indices = _listAddAll(this.indices, list);
return this;
}

/**
* Required - API name: {@code indices}
*
* <p>
* Adds one or more values to <code>indices</code>.
* </p>
*/
@Nonnull
public final Builder indices(IndicesBlockStatus value, IndicesBlockStatus... values) {
this.indices = _listAdd(this.indices, value, values);
return this;
}

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

@Override
protected Builder self() {
/**
* Required - API name: {@code shards_acknowledged}
*/
@Nonnull
public final Builder shardsAcknowledged(boolean value) {
this.shardsAcknowledged = value;
return this;
}

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

Expand All @@ -177,10 +224,27 @@ public AddBlockResponse build() {
);

protected static void setupAddBlockResponseDeserializer(ObjectDeserializer<AddBlockResponse.Builder> op) {
AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op);
op.add(Builder::shardsAcknowledged, JsonpDeserializer.booleanDeserializer(), "shards_acknowledged");
setupAcknowledgedResponseBaseDeserializer(op);
op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(IndicesBlockStatus._DESERIALIZER), "indices");
op.add(Builder::shardsAcknowledged, JsonpDeserializer.booleanDeserializer(), "shards_acknowledged");
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + this.indices.hashCode();
result = 31 * result + Boolean.hashCode(this.shardsAcknowledged);
return result;
}

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
AddBlockResponse other = (AddBlockResponse) o;
return this.indices.equals(other.indices) && this.shardsAcknowledged == other.shardsAcknowledged;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ public OpenSearchIndicesAsyncClientBase(OpenSearchTransport transport, @Nullable
super(transport, transportOptions);
}

// ----- Endpoint: indices.add_block

/**
* Adds a block to an index.
*/
public CompletableFuture<AddBlockResponse> addBlock(AddBlockRequest request) throws IOException, OpenSearchException {
return this.transport.performRequestAsync(request, AddBlockRequest._ENDPOINT, this.transportOptions);
}

/**
* Adds a block to an index.
*
* @param fn a function that initializes a builder to create the {@link AddBlockRequest}
*/
public final CompletableFuture<AddBlockResponse> addBlock(Function<AddBlockRequest.Builder, ObjectBuilder<AddBlockRequest>> fn)
throws IOException, OpenSearchException {
return addBlock(fn.apply(new AddBlockRequest.Builder()).build());
}

// ----- Endpoint: indices.create

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ public OpenSearchIndicesClientBase(OpenSearchTransport transport, @Nullable Tran
super(transport, transportOptions);
}

// ----- Endpoint: indices.add_block

/**
* Adds a block to an index.
*/
public AddBlockResponse addBlock(AddBlockRequest request) throws IOException, OpenSearchException {
return this.transport.performRequest(request, AddBlockRequest._ENDPOINT, this.transportOptions);
}

/**
* Adds a block to an index.
*
* @param fn a function that initializes a builder to create the {@link AddBlockRequest}
*/
public final AddBlockResponse addBlock(Function<AddBlockRequest.Builder, ObjectBuilder<AddBlockRequest>> fn) throws IOException,
OpenSearchException {
return addBlock(fn.apply(new AddBlockRequest.Builder()).build());
}

// ----- Endpoint: indices.create

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

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

package org.opensearch.client.opensearch.indices.add_block;

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

// typedef: indices.add_block.IndicesBlockOptions

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public enum IndicesBlockOptions implements JsonEnum {
Metadata("metadata"),

Read("read"),

ReadOnly("read_only"),

Write("write"),

;
Write("write");

private final String jsonValue;

Expand Down
Loading

0 comments on commit 26f63d2

Please sign in to comment.