Skip to content

Commit

Permalink
Rename restore request
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Dec 13, 2024
1 parent fb48675 commit 5291ad2
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 44 deletions.
3 changes: 2 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,6 @@ After:
### RepositorySettings
- The `concurrentStreams` property is now of type `Integer` instead of `String`.

### snapshot.RestoreRequest
### snapshot.RestoreRequest renamed to snapshot.RestoreSnapshotRequest
- The `snapshot.RestoreRequest` class has been renamed to `snapshot.RestoreSnapshotRequest`.
- The `indexSettings` property has been corrected to be of type `IndexSettings` instead of `PutIndicesSettingsRequest`.
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,19 @@ public final CompletableFuture<GetRepositoryResponse> getRepository() throws IOE
/**
* Restores a snapshot.
*/
public CompletableFuture<RestoreResponse> restore(RestoreRequest request) throws IOException, OpenSearchException {
return this.transport.performRequestAsync(request, RestoreRequest._ENDPOINT, this.transportOptions);
public CompletableFuture<RestoreSnapshotResponse> restore(RestoreSnapshotRequest request) throws IOException, OpenSearchException {
return this.transport.performRequestAsync(request, RestoreSnapshotRequest._ENDPOINT, this.transportOptions);
}

/**
* Restores a snapshot.
*
* @param fn a function that initializes a builder to create the {@link RestoreRequest}
* @param fn a function that initializes a builder to create the {@link RestoreSnapshotRequest}
*/
public final CompletableFuture<RestoreResponse> restore(Function<RestoreRequest.Builder, ObjectBuilder<RestoreRequest>> fn)
throws IOException, OpenSearchException {
return restore(fn.apply(new RestoreRequest.Builder()).build());
public final CompletableFuture<RestoreSnapshotResponse> restore(
Function<RestoreSnapshotRequest.Builder, ObjectBuilder<RestoreSnapshotRequest>> fn
) throws IOException, OpenSearchException {
return restore(fn.apply(new RestoreSnapshotRequest.Builder()).build());
}

// ----- Endpoint: snapshot.status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,18 @@ public final GetRepositoryResponse getRepository() throws IOException, OpenSearc
/**
* Restores a snapshot.
*/
public RestoreResponse restore(RestoreRequest request) throws IOException, OpenSearchException {
return this.transport.performRequest(request, RestoreRequest._ENDPOINT, this.transportOptions);
public RestoreSnapshotResponse restore(RestoreSnapshotRequest request) throws IOException, OpenSearchException {
return this.transport.performRequest(request, RestoreSnapshotRequest._ENDPOINT, this.transportOptions);
}

/**
* Restores a snapshot.
*
* @param fn a function that initializes a builder to create the {@link RestoreRequest}
* @param fn a function that initializes a builder to create the {@link RestoreSnapshotRequest}
*/
public final RestoreResponse restore(Function<RestoreRequest.Builder, ObjectBuilder<RestoreRequest>> fn) throws IOException,
OpenSearchException {
return restore(fn.apply(new RestoreRequest.Builder()).build());
public final RestoreSnapshotResponse restore(Function<RestoreSnapshotRequest.Builder, ObjectBuilder<RestoreSnapshotRequest>> fn)
throws IOException, OpenSearchException {
return restore(fn.apply(new RestoreSnapshotRequest.Builder()).build());
}

// ----- Endpoint: snapshot.status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
*/
@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class RestoreRequest extends RequestBase
public class RestoreSnapshotRequest extends RequestBase
implements
PlainJsonSerializable,
ToCopyableBuilder<RestoreRequest.Builder, RestoreRequest> {
ToCopyableBuilder<RestoreSnapshotRequest.Builder, RestoreSnapshotRequest> {

@Nullable
private final Time clusterManagerTimeout;
Expand Down Expand Up @@ -132,7 +132,7 @@ public class RestoreRequest extends RequestBase

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

private RestoreRequest(Builder builder) {
private RestoreSnapshotRequest(Builder builder) {
this.clusterManagerTimeout = builder.clusterManagerTimeout;
this.ignoreIndexSettings = ApiTypeHelper.unmodifiable(builder.ignoreIndexSettings);
this.ignoreUnavailable = builder.ignoreUnavailable;
Expand All @@ -153,7 +153,7 @@ private RestoreRequest(Builder builder) {
this.waitForCompletion = builder.waitForCompletion;
}

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

Expand Down Expand Up @@ -479,9 +479,9 @@ public static Builder builder() {
}

/**
* Builder for {@link RestoreRequest}.
* Builder for {@link RestoreSnapshotRequest}.
*/
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, RestoreRequest> {
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, RestoreSnapshotRequest> {
@Nullable
private Time clusterManagerTimeout;
@Nullable
Expand Down Expand Up @@ -519,7 +519,7 @@ public static class Builder extends ObjectBuilderBase implements CopyableBuilder

public Builder() {}

private Builder(RestoreRequest o) {
private Builder(RestoreSnapshotRequest o) {
this.clusterManagerTimeout = o.clusterManagerTimeout;
this.ignoreIndexSettings = _listCopy(o.ignoreIndexSettings);
this.ignoreUnavailable = o.ignoreUnavailable;
Expand Down Expand Up @@ -887,30 +887,30 @@ public final Builder waitForCompletion(@Nullable Boolean value) {
}

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

return new RestoreRequest(this);
return new RestoreSnapshotRequest(this);
}
}

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

/**
* Json deserializer for {@link RestoreRequest}
* Json deserializer for {@link RestoreSnapshotRequest}
*/
public static final JsonpDeserializer<RestoreRequest> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
public static final JsonpDeserializer<RestoreSnapshotRequest> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
Builder::new,
RestoreRequest::setupRestoreRequestDeserializer
RestoreSnapshotRequest::setupRestoreSnapshotRequestDeserializer
);

protected static void setupRestoreRequestDeserializer(ObjectDeserializer<RestoreRequest.Builder> op) {
protected static void setupRestoreSnapshotRequestDeserializer(ObjectDeserializer<RestoreSnapshotRequest.Builder> op) {
op.add(
Builder::ignoreIndexSettings,
JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()),
Expand All @@ -937,7 +937,7 @@ protected static void setupRestoreRequestDeserializer(ObjectDeserializer<Restore
/**
* Endpoint "{@code snapshot.restore}".
*/
public static final Endpoint<RestoreRequest, RestoreResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(
public static final Endpoint<RestoreSnapshotRequest, RestoreSnapshotResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(
// Request method
request -> "POST",
// Request path
Expand Down Expand Up @@ -966,7 +966,7 @@ protected static void setupRestoreRequestDeserializer(ObjectDeserializer<Restore
},
SimpleEndpoint.emptyMap(),
true,
RestoreResponse._DESERIALIZER
RestoreSnapshotResponse._DESERIALIZER
);

@Override
Expand Down Expand Up @@ -997,7 +997,7 @@ public int hashCode() {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
RestoreRequest other = (RestoreRequest) o;
RestoreSnapshotRequest other = (RestoreSnapshotRequest) o;
return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout)
&& Objects.equals(this.ignoreIndexSettings, other.ignoreIndexSettings)
&& Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class RestoreResponse implements PlainJsonSerializable, ToCopyableBuilder<RestoreResponse.Builder, RestoreResponse> {
public class RestoreSnapshotResponse
implements
PlainJsonSerializable,
ToCopyableBuilder<RestoreSnapshotResponse.Builder, RestoreSnapshotResponse> {

@Nullable
private final Boolean accepted;
Expand All @@ -68,12 +71,12 @@ public class RestoreResponse implements PlainJsonSerializable, ToCopyableBuilder

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

private RestoreResponse(Builder builder) {
private RestoreSnapshotResponse(Builder builder) {
this.accepted = builder.accepted;
this.snapshot = builder.snapshot;
}

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

Expand Down Expand Up @@ -133,17 +136,17 @@ public static Builder builder() {
}

/**
* Builder for {@link RestoreResponse}.
* Builder for {@link RestoreSnapshotResponse}.
*/
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, RestoreResponse> {
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, RestoreSnapshotResponse> {
@Nullable
private Boolean accepted;
@Nullable
private SnapshotRestore snapshot;

public Builder() {}

private Builder(RestoreResponse o) {
private Builder(RestoreSnapshotResponse o) {
this.accepted = o.accepted;
this.snapshot = o.snapshot;
}
Expand Down Expand Up @@ -190,30 +193,30 @@ public final Builder snapshot(Function<SnapshotRestore.Builder, ObjectBuilder<Sn
}

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

return new RestoreResponse(this);
return new RestoreSnapshotResponse(this);
}
}

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

/**
* Json deserializer for {@link RestoreResponse}
* Json deserializer for {@link RestoreSnapshotResponse}
*/
public static final JsonpDeserializer<RestoreResponse> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
public static final JsonpDeserializer<RestoreSnapshotResponse> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
Builder::new,
RestoreResponse::setupRestoreResponseDeserializer
RestoreSnapshotResponse::setupRestoreSnapshotResponseDeserializer
);

protected static void setupRestoreResponseDeserializer(ObjectDeserializer<RestoreResponse.Builder> op) {
protected static void setupRestoreSnapshotResponseDeserializer(ObjectDeserializer<RestoreSnapshotResponse.Builder> op) {
op.add(Builder::accepted, JsonpDeserializer.booleanDeserializer(), "accepted");
op.add(Builder::snapshot, SnapshotRestore._DESERIALIZER, "snapshot");
}
Expand All @@ -230,7 +233,7 @@ public int hashCode() {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
RestoreResponse other = (RestoreResponse) o;
RestoreSnapshotResponse other = (RestoreSnapshotResponse) o;
return Objects.equals(this.accepted, other.accepted) && Objects.equals(this.snapshot, other.snapshot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ private static String classBaseName(@Nonnull OperationGroup operationGroup) {
return "DeleteSnapshot";
case "snapshot.get":
return "GetSnapshot";
case "snapshot.restore":
return "RestoreSnapshot";
case "snapshot.status":
return "SnapshotStatus";
case "tasks.get":
Expand Down

0 comments on commit 5291ad2

Please sign in to comment.