Skip to content

Commit

Permalink
Generate more indices operations (#1342)
Browse files Browse the repository at this point in the history
* Generate indices.delete_template

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

* Generate indices.exists_template

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

* Generate indices.put_template and indices.simulate_template

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

* Generate indices.get_settings

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

* Generate indices.put_settings

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

* Generate indices.get_mapping and indices.put_mapping

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

* Adjust matching

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

* Fix

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

---------

Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia authored Dec 9, 2024
1 parent 75ff633 commit 6a5b947
Show file tree
Hide file tree
Showing 44 changed files with 3,919 additions and 2,589 deletions.
10 changes: 9 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,12 @@ After:

### QueryStringQuery
- The `phraseSlop` property has been corrected to be of type `Integer` instead of `Double`.
- The `tieBreaker` property has been corrected to be of type `Float` instead of `Double`.
- The `tieBreaker` property has been corrected to be of type `Float` instead of `Double`.

### simulate_template.Template
- The `settings` property is now of type `IndexSettings` instead of `Map<String, JsonData>`.
- The `overlapping` property has been moved to `SimulateTemplateResponse`.

### PutTemplateRequest
- The `flatSettings` property has been removed as it is not supported by OpenSearch.
- The `timeout` property has been removed as it is not supported by OpenSearch.
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,46 @@
* GitHub history for details.
*/

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

package org.opensearch.client.opensearch.indices;

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: indices.delete_template.Request

/**
* Deletes an index template.
*
*/
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class DeleteTemplateRequest extends RequestBase implements ToCopyableBuilder<DeleteTemplateRequest.Builder, DeleteTemplateRequest> {

public class DeleteTemplateRequest 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 name;

@Nullable
Expand All @@ -68,52 +78,56 @@ public class DeleteTemplateRequest extends RequestBase {
// ---------------------------------------------------------------------------------------------

private DeleteTemplateRequest(Builder builder) {

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

}

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

/**
* Specify timeout for connection to master
* 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;
}

/**
* Specify timeout for connection to cluster-manager
* Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails
* and returns an error.
* <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 - The name of the template
* Required - The name of the legacy index template to delete. Wildcard (<code>*</code>) expressions are supported.
* <p>
* API name: {@code name}
* </p>
*/
@Nonnull
public final String name() {
return this.name;
}

/**
* Explicit operation timeout
* Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
* <p>
* API name: {@code timeout}
* </p>
*/
@Nullable
public final Time timeout() {
Expand All @@ -122,98 +136,143 @@ public final Time timeout() {

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

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

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

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

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

public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, DeleteTemplateRequest> {
@Nullable
private Time clusterManagerTimeout;

@Nullable
private Time masterTimeout;
private String name;

@Nullable
private Time timeout;

public Builder() {}

private Builder(DeleteTemplateRequest o) {
this.clusterManagerTimeout = o.clusterManagerTimeout;
this.masterTimeout = o.masterTimeout;
this.name = o.name;
this.timeout = o.timeout;
}

private Builder(Builder o) {
this.clusterManagerTimeout = o.clusterManagerTimeout;
this.masterTimeout = o.masterTimeout;
this.name = o.name;
this.timeout = o.timeout;
}

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

/**
* Specify timeout for connection to master
* 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;
@Nonnull
public final Builder clusterManagerTimeout(@Nullable Time value) {
this.clusterManagerTimeout = value;
return this;
}

/**
* Specify timeout for connection to master
* 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());
@Nonnull
public final Builder clusterManagerTimeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return clusterManagerTimeout(fn.apply(new Time.Builder()).build());
}

/**
* Specify timeout for connection to cluster-manager
* Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request
* fails and returns an error.
* <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;
}

/**
* Specify timeout for connection to cluster-manager
* Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request
* fails and returns an error.
* <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 - The name of the template
* Required - The name of the legacy index template to delete. Wildcard (<code>*</code>) expressions are supported.
* <p>
* API name: {@code name}
* </p>
*/
@Nonnull
public final Builder name(String value) {
this.name = value;
return this;
}

/**
* Explicit operation timeout
* Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
* <p>
* API name: {@code timeout}
* </p>
*/
@Nonnull
public final Builder timeout(@Nullable Time value) {
this.timeout = value;
return this;
}

/**
* Explicit operation timeout
* Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
* <p>
* API name: {@code timeout}
* </p>
*/
@Nonnull
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 DeleteTemplateRequest}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
@Override
@Nonnull
public DeleteTemplateRequest build() {
_checkSingleUse();

Expand All @@ -227,49 +286,52 @@ public DeleteTemplateRequest build() {
* Endpoint "{@code indices.delete_template}".
*/
public static final Endpoint<DeleteTemplateRequest, DeleteTemplateResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(

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

},

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

int propsSet = 0;

propsSet |= _name;

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

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

},
SimpleEndpoint.emptyMap(),
false,
DeleteTemplateResponse._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.name.hashCode();
result = 31 * result + Objects.hashCode(this.timeout);
return result;
}

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

0 comments on commit 6a5b947

Please sign in to comment.