Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate GetSnapshot #1299

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

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

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

package org.opensearch.client.opensearch.snapshot;

import jakarta.json.stream.JsonGenerator;
import java.util.List;
import java.util.function.Function;
import javax.annotation.Nullable;
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;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch.snapshot.get.SnapshotResponseItem;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;

// typedef: snapshot.get.Response

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class GetSnapshotResponse implements PlainJsonSerializable {
private final List<SnapshotResponseItem> responses;

@Nonnull
private final List<SnapshotInfo> snapshots;

private final int total;

private final int remaining;

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

private GetSnapshotResponse(Builder builder) {

this.responses = ApiTypeHelper.unmodifiable(builder.responses);
this.snapshots = ApiTypeHelper.unmodifiable(builder.snapshots);
this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total");
this.remaining = ApiTypeHelper.requireNonNull(builder.remaining, this, "remaining");

this.snapshots = ApiTypeHelper.unmodifiableRequired(builder.snapshots, this, "snapshots");
}

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

/**
* API name: {@code responses}
*/
public final List<SnapshotResponseItem> responses() {
return this.responses;
}

/**
* API name: {@code snapshots}
* Required - API name: {@code snapshots}
*/
@Nonnull
public final List<SnapshotInfo> snapshots() {
return this.snapshots;
}

/**
* Required - The total number of snapshots that match the request when ignoring
* size limit or after query parameter.
* <p>
* API name: {@code total}
*/
public final int total() {
return this.total;
}

/**
* Required - The number of remaining snapshots that were not returned due to
* size limits and that can be fetched by additional requests using the next
* field value.
* <p>
* API name: {@code remaining}
*/
public final int remaining() {
return this.remaining;
}

/**
* 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 (ApiTypeHelper.isDefined(this.responses)) {
generator.writeKey("responses");
generator.writeStartArray();
for (SnapshotResponseItem item0 : this.responses) {
item0.serialize(generator, mapper);

}
generator.writeEnd();

}
if (ApiTypeHelper.isDefined(this.snapshots)) {
generator.writeKey("snapshots");
generator.writeStartArray();
for (SnapshotInfo item0 : this.snapshots) {
item0.serialize(generator, mapper);

}
generator.writeEnd();

generator.writeKey("snapshots");
generator.writeStartArray();
for (SnapshotInfo item0 : this.snapshots) {
item0.serialize(generator, mapper);
}
generator.writeKey("total");
generator.write(this.total);

generator.writeKey("remaining");
generator.write(this.remaining);

generator.writeEnd();
}

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

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

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<GetSnapshotResponse> {
@Nullable
private List<SnapshotResponseItem> responses;

@Nullable
private List<SnapshotInfo> snapshots;

private Integer total;

private Integer remaining;

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

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

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

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

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

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

/**
* Required - The total number of snapshots that match the request when ignoring
* size limit or after query parameter.
* <p>
* API name: {@code total}
*/
public final Builder total(int value) {
this.total = value;
return this;
}

/**
* Required - The number of remaining snapshots that were not returned due to
* size limits and that can be fetched by additional requests using the next
* field value.
* <p>
* API name: {@code remaining}
*/
public final Builder remaining(int value) {
this.remaining = value;
return this;
}

/**
* Builds a {@link GetSnapshotResponse}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
public GetSnapshotResponse build() {
_checkSingleUse();
Expand All @@ -270,12 +163,21 @@ public GetSnapshotResponse build() {
);

protected static void setupGetSnapshotResponseDeserializer(ObjectDeserializer<GetSnapshotResponse.Builder> op) {

op.add(Builder::responses, JsonpDeserializer.arrayDeserializer(SnapshotResponseItem._DESERIALIZER), "responses");
op.add(Builder::snapshots, JsonpDeserializer.arrayDeserializer(SnapshotInfo._DESERIALIZER), "snapshots");
op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total");
op.add(Builder::remaining, JsonpDeserializer.integerDeserializer(), "remaining");
}

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

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
GetSnapshotResponse other = (GetSnapshotResponse) o;
return this.snapshots.equals(other.snapshots);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ public final CompletableFuture<CloneSnapshotResponse> clone(
return clone(fn.apply(new CloneSnapshotRequest.Builder()).build());
}

// ----- Endpoint: snapshot.get

/**
* Returns information about a snapshot.
*/
public CompletableFuture<GetSnapshotResponse> get(GetSnapshotRequest request) throws IOException, OpenSearchException {
return this.transport.performRequestAsync(request, GetSnapshotRequest._ENDPOINT, this.transportOptions);
}

/**
* Returns information about a snapshot.
*
* @param fn a function that initializes a builder to create the {@link GetSnapshotRequest}
*/
public final CompletableFuture<GetSnapshotResponse> get(Function<GetSnapshotRequest.Builder, ObjectBuilder<GetSnapshotRequest>> fn)
throws IOException, OpenSearchException {
return get(fn.apply(new GetSnapshotRequest.Builder()).build());
}

// ----- Endpoint: snapshot.verify_repository

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ public final CloneSnapshotResponse clone(Function<CloneSnapshotRequest.Builder,
return clone(fn.apply(new CloneSnapshotRequest.Builder()).build());
}

// ----- Endpoint: snapshot.get

/**
* Returns information about a snapshot.
*/
public GetSnapshotResponse get(GetSnapshotRequest request) throws IOException, OpenSearchException {
return this.transport.performRequest(request, GetSnapshotRequest._ENDPOINT, this.transportOptions);
}

/**
* Returns information about a snapshot.
*
* @param fn a function that initializes a builder to create the {@link GetSnapshotRequest}
*/
public final GetSnapshotResponse get(Function<GetSnapshotRequest.Builder, ObjectBuilder<GetSnapshotRequest>> fn) throws IOException,
OpenSearchException {
return get(fn.apply(new GetSnapshotRequest.Builder()).build());
}

// ----- Endpoint: snapshot.verify_repository

/**
Expand Down
Loading
Loading