Skip to content

Commit

Permalink
Begin generating snapshot namespace (#1207)
Browse files Browse the repository at this point in the history
* Generate snapshot.verify_snapshot

Signed-off-by: Thomas Farr <[email protected]>

* Generate snapshot.cleanup_snapshot

Signed-off-by: Thomas Farr <[email protected]>

* Generate snapshot.clone

Signed-off-by: Thomas Farr <[email protected]>

---------

Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia authored Sep 24, 2024
1 parent 6a5a8cc commit 851ab58
Show file tree
Hide file tree
Showing 19 changed files with 565 additions and 567 deletions.
11 changes: 10 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,13 @@ After:
- The `tasks` field is now a `TaskInfos` union type instead of a `Map<String, Info>` to correctly handle `groupBy` parents or none.

### GetTasksResponse response type
- The type of `GetTasksResponse`'s `response` field has been changed from `tasks.Status` to `tasks.TaskResponse`.
- The type of `GetTasksResponse`'s `response` field has been changed from `tasks.Status` to `tasks.TaskResponse`.

### VerifyRepositoryRequest property naming
- The `name` field, getter and builder method have been renamed to `repository`.

### CleanupRepositoryRequest property naming
- The `name` field, getter and builder method have been renamed to `repository`.

### CloneSnapshotRequest timeout removal
- The `timeout` field, getter and builder method have been removed from `CloneSnapshotRequest` as it is not supported by OpenSearch.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.opensearch.client.opensearch.core.InfoResponse;
import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesAsyncClient;
import org.opensearch.client.opensearch.ml.OpenSearchMlAsyncClient;
import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotAsyncClient;
import org.opensearch.client.opensearch.tasks.OpenSearchTasksAsyncClient;
import org.opensearch.client.transport.OpenSearchTransport;
import org.opensearch.client.transport.TransportOptions;
Expand All @@ -69,6 +70,10 @@ public OpenSearchMlAsyncClient ml() {
return new OpenSearchMlAsyncClient(this.transport, this.transportOptions);
}

public OpenSearchSnapshotAsyncClient snapshot() {
return new OpenSearchSnapshotAsyncClient(this.transport, this.transportOptions);
}

public OpenSearchTasksAsyncClient tasks() {
return new OpenSearchTasksAsyncClient(this.transport, this.transportOptions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.opensearch.client.opensearch.core.InfoResponse;
import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesClient;
import org.opensearch.client.opensearch.ml.OpenSearchMlClient;
import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotClient;
import org.opensearch.client.opensearch.tasks.OpenSearchTasksClient;
import org.opensearch.client.transport.OpenSearchTransport;
import org.opensearch.client.transport.TransportOptions;
Expand All @@ -68,6 +69,10 @@ public OpenSearchMlClient ml() {
return new OpenSearchMlClient(this.transport, this.transportOptions);
}

public OpenSearchSnapshotClient snapshot() {
return new OpenSearchSnapshotClient(this.transport, this.transportOptions);
}

public OpenSearchTasksClient tasks() {
return new OpenSearchTasksClient(this.transport, this.transportOptions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@
* 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.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
Expand All @@ -49,71 +54,73 @@

/**
* Removes stale data from repository.
*
*/

@Generated("org.opensearch.client.codegen.CodeGenerator")
public class CleanupRepositoryRequest extends RequestBase {
@Deprecated
@Nullable
private final Time masterTimeout;

@Nullable
private final Time clusterManagerTimeout;

private final String name;
@Deprecated
@Nullable
private final Time masterTimeout;

private final String repository;

@Nullable
private final Time timeout;

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

private CleanupRepositoryRequest(Builder builder) {

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

}

public static CleanupRepositoryRequest of(Function<Builder, ObjectBuilder<CleanupRepositoryRequest>> fn) {
public static CleanupRepositoryRequest of(Function<CleanupRepositoryRequest.Builder, ObjectBuilder<CleanupRepositoryRequest>> 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>
*/
@Deprecated
@Nullable
public final Time masterTimeout() {
return this.masterTimeout;
public final Time clusterManagerTimeout() {
return this.clusterManagerTimeout;
}

/**
* Explicit operation timeout for connection to cluster-manager node
* Period to wait for a connection to the master 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
* Required - Snapshot repository to clean up.
* <p>
* API name: {@code repository}
* </p>
*/
public final String name() {
return this.name;
public final String repository() {
return this.repository;
}

/**
* Explicit operation timeout
* Period to wait for a response.
* <p>
* API name: {@code timeout}
* </p>
*/
@Nullable
public final Time timeout() {
Expand All @@ -125,94 +132,95 @@ public final Time timeout() {
/**
* Builder for {@link CleanupRepositoryRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<CleanupRepositoryRequest> {
@Deprecated
@Nullable
private Time masterTimeout;

@Nullable
private Time clusterManagerTimeout;

private String name;

@Nullable
private Time masterTimeout;
private String repository;
@Nullable
private Time timeout;

/**
* 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>
*/
@Deprecated
public final Builder masterTimeout(@Nullable Time value) {
this.masterTimeout = value;
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>
*/
@Deprecated
public final Builder masterTimeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return this.masterTimeout(fn.apply(new Time.Builder()).build());
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
* Period to wait for a connection to the master 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
public final Builder masterTimeout(@Nullable Time value) {
this.masterTimeout = value;
return this;
}

/**
* Explicit operation timeout for connection to cluster-manager node
* Period to wait for a connection to the master 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
public final Builder masterTimeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return masterTimeout(fn.apply(new Time.Builder()).build());
}

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

/**
* Explicit operation timeout
* Period to wait for a response.
* <p>
* API name: {@code timeout}
* </p>
*/
public final Builder timeout(@Nullable Time value) {
this.timeout = value;
return this;
}

/**
* Explicit operation timeout
* Period to wait for a response.
* <p>
* API name: {@code timeout}
* </p>
*/
public final Builder timeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return this.timeout(fn.apply(new Time.Builder()).build());
return timeout(fn.apply(new Time.Builder()).build());
}

/**
* Builds a {@link CleanupRepositoryRequest}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
public CleanupRepositoryRequest build() {
_checkSingleUse();
Expand All @@ -227,47 +235,29 @@ public CleanupRepositoryRequest build() {
* Endpoint "{@code snapshot.cleanup_repository}".
*/
public static final Endpoint<CleanupRepositoryRequest, CleanupRepositoryResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(

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

},

request -> "POST",
// Request path
request -> {
final int _name = 1 << 0;

int propsSet = 0;

propsSet |= _name;

if (propsSet == (_name)) {
StringBuilder buf = new StringBuilder();
buf.append("/_snapshot");
buf.append("/");
SimpleEndpoint.pathEncode(request.name, buf);
buf.append("/_cleanup");
return buf.toString();
}
throw SimpleEndpoint.noPathTemplateFound("path");

StringBuilder buf = new StringBuilder();
buf.append("/_snapshot/");
SimpleEndpoint.pathEncode(request.repository, buf);
buf.append("/_cleanup");
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());
}
if (request.timeout != null) {
params.put("timeout", request.timeout._toJsonString());
}
return params;

},
SimpleEndpoint.emptyMap(),
false,
Expand Down
Loading

0 comments on commit 851ab58

Please sign in to comment.