Skip to content

Commit

Permalink
Generate remaining snapshot requests
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Dec 12, 2024
1 parent 76b7df2 commit fb48675
Show file tree
Hide file tree
Showing 27 changed files with 2,689 additions and 1,737 deletions.
5 changes: 4 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,7 @@ After:
- `DataStream`'s (previously `DataStreamInfo`) `indices` field.

### RepositorySettings
- The `concurrentStreams` property is now of type `Integer` instead of `String`.
- The `concurrentStreams` property is now of type `Integer` instead of `String`.

### snapshot.RestoreRequest
- 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 @@ -30,164 +30,222 @@
* GitHub history for details.
*/

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

package org.opensearch.client.opensearch.snapshot;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.opensearch._types.Time;
import org.opensearch.client.transport.Endpoint;
import org.opensearch.client.transport.endpoints.SimpleEndpoint;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.CopyableBuilder;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;
import org.opensearch.client.util.ToCopyableBuilder;

// typedef: snapshot.delete.Request

/**
* Deletes a snapshot.
*
*/
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class DeleteSnapshotRequest extends RequestBase implements ToCopyableBuilder<DeleteSnapshotRequest.Builder, DeleteSnapshotRequest> {

public class DeleteSnapshotRequest extends RequestBase {
@Deprecated
@Nullable
private final Time masterTimeout;
private final Time clusterManagerTimeout;

@Deprecated
@Nullable
private final Time clusterManagerTimeout;
private final Time masterTimeout;

@Nonnull
private final String repository;

@Nonnull
private final String snapshot;

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

private DeleteSnapshotRequest(Builder builder) {

this.masterTimeout = builder.masterTimeout;
this.clusterManagerTimeout = builder.clusterManagerTimeout;
this.masterTimeout = builder.masterTimeout;
this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository");
this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot");

}

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

/**
* Explicit operation timeout for connection to master node
* Operation timeout for connection to cluster-manager node.
* <p>
* API name: {@code master_timeout}
* API name: {@code cluster_manager_timeout}
* </p>
*/
@Nullable
public final Time masterTimeout() {
return this.masterTimeout;
public final Time clusterManagerTimeout() {
return this.clusterManagerTimeout;
}

/**
* Explicit operation timeout for connection to cluster-manager node
* <p>
* API name: {@code cluster_manager_timeout}
* API name: {@code master_timeout}
* </p>
*/
@Deprecated
@Nullable
public final Time clusterManagerTimeout() {
return this.clusterManagerTimeout;
public final Time masterTimeout() {
return this.masterTimeout;
}

/**
* Required - A repository name
* <p>
* API name: {@code repository}
* </p>
*/
@Nonnull
public final String repository() {
return this.repository;
}

/**
* Required - A snapshot name
* Required - A comma-separated list of snapshot names
* <p>
* API name: {@code snapshot}
* </p>
*/
@Nonnull
public final String snapshot() {
return this.snapshot;
}

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

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

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

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

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<DeleteSnapshotRequest> {
@Deprecated
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, DeleteSnapshotRequest> {
@Nullable
private Time clusterManagerTimeout;
@Nullable
private Time masterTimeout;
private String repository;
private String snapshot;

@Nullable
private Time clusterManagerTimeout;
public Builder() {}

private String repository;
private Builder(DeleteSnapshotRequest o) {
this.clusterManagerTimeout = o.clusterManagerTimeout;
this.masterTimeout = o.masterTimeout;
this.repository = o.repository;
this.snapshot = o.snapshot;
}

private String snapshot;
private Builder(Builder o) {
this.clusterManagerTimeout = o.clusterManagerTimeout;
this.masterTimeout = o.masterTimeout;
this.repository = o.repository;
this.snapshot = o.snapshot;
}

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

/**
* Explicit operation timeout for connection to master node
* Operation timeout for connection to cluster-manager node.
* <p>
* API name: {@code master_timeout}
* API name: {@code cluster_manager_timeout}
* </p>
*/
public final Builder masterTimeout(@Nullable Time value) {
this.masterTimeout = value;
@Nonnull
public final Builder clusterManagerTimeout(@Nullable Time value) {
this.clusterManagerTimeout = value;
return this;
}

/**
* Explicit operation timeout for connection to master node
* Operation timeout for connection to cluster-manager node.
* <p>
* API name: {@code master_timeout}
* API name: {@code cluster_manager_timeout}
* </p>
*/
public final Builder masterTimeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return this.masterTimeout(fn.apply(new Time.Builder()).build());
@Nonnull
public final Builder clusterManagerTimeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return clusterManagerTimeout(fn.apply(new Time.Builder()).build());
}

/**
* Explicit operation timeout for connection to cluster-manager node
* <p>
* API name: {@code cluster_manager_timeout}
* API name: {@code master_timeout}
* </p>
*/
public final Builder clusterManagerTimeout(@Nullable Time value) {
this.clusterManagerTimeout = value;
@Deprecated
@Nonnull
public final Builder masterTimeout(@Nullable Time value) {
this.masterTimeout = value;
return this;
}

/**
* Explicit operation timeout for connection to cluster-manager node
* <p>
* API name: {@code cluster_manager_timeout}
* API name: {@code master_timeout}
* </p>
*/
public final Builder clusterManagerTimeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build());
@Deprecated
@Nonnull
public final Builder masterTimeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return masterTimeout(fn.apply(new Time.Builder()).build());
}

/**
* Required - A repository name
* <p>
* API name: {@code repository}
* </p>
*/
@Nonnull
public final Builder repository(String value) {
this.repository = value;
return this;
}

/**
* Required - A snapshot name
* Required - A comma-separated list of snapshot names
* <p>
* API name: {@code snapshot}
* </p>
*/
@Nonnull
public final Builder snapshot(String value) {
this.snapshot = value;
return this;
Expand All @@ -196,9 +254,10 @@ public final Builder snapshot(String value) {
/**
* Builds a {@link DeleteSnapshotRequest}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
@Override
@Nonnull
public DeleteSnapshotRequest build() {
_checkSingleUse();

Expand All @@ -212,50 +271,51 @@ public DeleteSnapshotRequest build() {
* Endpoint "{@code snapshot.delete}".
*/
public static final Endpoint<DeleteSnapshotRequest, DeleteSnapshotResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(

// Request method
request -> {
return "DELETE";

},

request -> "DELETE",
// Request path
request -> {
final int _repository = 1 << 0;
final int _snapshot = 1 << 1;

int propsSet = 0;

propsSet |= _repository;
propsSet |= _snapshot;

if (propsSet == (_repository | _snapshot)) {
StringBuilder buf = new StringBuilder();
buf.append("/_snapshot");
buf.append("/");
SimpleEndpoint.pathEncode(request.repository, buf);
buf.append("/");
SimpleEndpoint.pathEncode(request.snapshot, buf);
return buf.toString();
}
throw SimpleEndpoint.noPathTemplateFound("path");

StringBuilder buf = new StringBuilder();
buf.append("/_snapshot/");
SimpleEndpoint.pathEncode(request.repository, buf);
buf.append("/");
SimpleEndpoint.pathEncode(request.snapshot, buf);
return buf.toString();
},

// Request parameters
request -> {
Map<String, String> params = new HashMap<>();
if (request.masterTimeout != null) {
params.put("master_timeout", request.masterTimeout._toJsonString());
}
if (request.clusterManagerTimeout != null) {
params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString());
}
if (request.masterTimeout != null) {
params.put("master_timeout", request.masterTimeout._toJsonString());
}
return params;

},
SimpleEndpoint.emptyMap(),
false,
DeleteSnapshotResponse._DESERIALIZER
);

@Override
public int hashCode() {
int result = 17;
result = 31 * result + Objects.hashCode(this.clusterManagerTimeout);
result = 31 * result + Objects.hashCode(this.masterTimeout);
result = 31 * result + this.repository.hashCode();
result = 31 * result + this.snapshot.hashCode();
return result;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
DeleteSnapshotRequest other = (DeleteSnapshotRequest) o;
return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout)
&& Objects.equals(this.masterTimeout, other.masterTimeout)
&& this.repository.equals(other.repository)
&& this.snapshot.equals(other.snapshot);
}
}
Loading

0 comments on commit fb48675

Please sign in to comment.