diff --git a/UPGRADING.md b/UPGRADING.md index f98573bf9c..09f333f642 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -160,4 +160,7 @@ After: ### DataStreamIndexInfo renamed to DataStreamIndex - The `DataStreamIndexInfo` class has been renamed to `DataStreamIndex`, this affects: - - `DataStream`'s (previously `DataStreamInfo`) `indices` field. \ No newline at end of file + - `DataStream`'s (previously `DataStreamInfo`) `indices` field. + +### RepositorySettings +- The `concurrentStreams` property is now of type `Integer` instead of `String`. \ No newline at end of file diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java index dfe04f47e8..28645f58d8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java @@ -30,12 +30,19 @@ * 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.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.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -49,34 +56,43 @@ 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.create_repository.Request /** * Creates a repository. - * */ @JsonpDeserializable -public class CreateRepositoryRequest extends RequestBase implements PlainJsonSerializable { - @Deprecated - @Nullable - private final Time masterTimeout; +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class CreateRepositoryRequest extends RequestBase + implements + PlainJsonSerializable, + ToCopyableBuilder { @Nullable private final Time clusterManagerTimeout; + @Deprecated + @Nullable + private final Time masterTimeout; + + @Nonnull private final String name; @Nullable private final Repository repository; + @Nonnull private final RepositorySettings settings; @Nullable private final Time timeout; + @Nonnull private final String type; @Nullable @@ -85,48 +101,50 @@ public class CreateRepositoryRequest extends RequestBase implements PlainJsonSer // --------------------------------------------------------------------------------------------- private CreateRepositoryRequest(Builder builder) { - - this.masterTimeout = builder.masterTimeout; this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.masterTimeout = builder.masterTimeout; this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.repository = builder.repository; this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); this.timeout = builder.timeout; this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); this.verify = builder.verify; - } - public static CreateRepositoryRequest of(Function> fn) { + public static CreateRepositoryRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Explicit operation timeout for connection to master node + * Operation timeout for connection to cluster-manager node. *

- * API name: {@code master_timeout} + * API name: {@code cluster_manager_timeout} + *

*/ - @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 *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ + @Deprecated @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; + public final Time masterTimeout() { + return this.masterTimeout; } /** * Required - A repository name *

* API name: {@code repository} + *

*/ + @Nonnull public final String name() { return this.name; } @@ -142,6 +160,7 @@ public final Repository repository() { /** * Required - API name: {@code settings} */ + @Nonnull public final RepositorySettings settings() { return this.settings; } @@ -150,6 +169,7 @@ public final RepositorySettings settings() { * Explicit operation timeout *

* API name: {@code timeout} + *

*/ @Nullable public final Time timeout() { @@ -159,6 +179,7 @@ public final Time timeout() { /** * Required - API name: {@code type} */ + @Nonnull public final String type() { return this.type; } @@ -167,6 +188,7 @@ public final String type() { * Whether to verify the repository after creation *

* API name: {@code verify} + *

*/ @Nullable public final Boolean verify() { @@ -176,6 +198,7 @@ public final Boolean verify() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -183,94 +206,133 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.repository != null) { generator.writeKey("repository"); this.repository.serialize(generator, mapper); - } + generator.writeKey("settings"); this.settings.serialize(generator, mapper); generator.writeKey("type"); generator.write(this.type); + } + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link CreateRepositoryRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Deprecated - @Nullable - private Time masterTimeout; - + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private Time clusterManagerTimeout; - + @Nullable + private Time masterTimeout; private String name; - @Nullable private Repository repository; - private RepositorySettings settings; - @Nullable private Time timeout; - private String type; - @Nullable private Boolean verify; + public Builder() {} + + private Builder(CreateRepositoryRequest o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.masterTimeout = o.masterTimeout; + this.name = o.name; + this.repository = o.repository; + this.settings = o.settings; + this.timeout = o.timeout; + this.type = o.type; + this.verify = o.verify; + } + + private Builder(Builder o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.masterTimeout = o.masterTimeout; + this.name = o.name; + this.repository = o.repository; + this.settings = o.settings; + this.timeout = o.timeout; + this.type = o.type; + this.verify = o.verify; + } + + @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. *

- * API name: {@code master_timeout} + * API name: {@code cluster_manager_timeout} + *

*/ - @Deprecated - 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. *

- * API name: {@code master_timeout} + * API name: {@code cluster_manager_timeout} + *

*/ - @Deprecated - public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); + @Nonnull + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); } /** * Explicit operation timeout for connection to cluster-manager node *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ - 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 *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + @Deprecated + @Nonnull + public final Builder masterTimeout(Function> fn) { + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** * Required - A repository name *

* API name: {@code repository} + *

*/ + @Nonnull public final Builder name(String value) { this.name = value; return this; @@ -279,6 +341,7 @@ public final Builder name(String value) { /** * API name: {@code repository} */ + @Nonnull public final Builder repository(@Nullable Repository value) { this.repository = value; return this; @@ -287,13 +350,15 @@ public final Builder repository(@Nullable Repository value) { /** * API name: {@code repository} */ + @Nonnull public final Builder repository(Function> fn) { - return this.repository(fn.apply(new Repository.Builder()).build()); + return repository(fn.apply(new Repository.Builder()).build()); } /** * Required - API name: {@code settings} */ + @Nonnull public final Builder settings(RepositorySettings value) { this.settings = value; return this; @@ -302,15 +367,18 @@ public final Builder settings(RepositorySettings value) { /** * Required - API name: {@code settings} */ + @Nonnull public final Builder settings(Function> fn) { - return this.settings(fn.apply(new RepositorySettings.Builder()).build()); + return settings(fn.apply(new RepositorySettings.Builder()).build()); } /** * Explicit operation timeout *

* API name: {@code timeout} + *

*/ + @Nonnull public final Builder timeout(@Nullable Time value) { this.timeout = value; return this; @@ -320,14 +388,17 @@ public final Builder timeout(@Nullable Time value) { * Explicit operation timeout *

* API name: {@code timeout} + *

*/ + @Nonnull public final Builder timeout(Function> fn) { - return this.timeout(fn.apply(new Time.Builder()).build()); + return timeout(fn.apply(new Time.Builder()).build()); } /** * Required - API name: {@code type} */ + @Nonnull public final Builder type(String value) { this.type = value; return this; @@ -337,7 +408,9 @@ public final Builder type(String value) { * Whether to verify the repository after creation *

* API name: {@code verify} + *

*/ + @Nonnull public final Builder verify(@Nullable Boolean value) { this.verify = value; return this; @@ -346,9 +419,10 @@ public final Builder verify(@Nullable Boolean value) { /** * Builds a {@link CreateRepositoryRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public CreateRepositoryRequest build() { _checkSingleUse(); @@ -367,11 +441,10 @@ public CreateRepositoryRequest build() { ); protected static void setupCreateRepositoryRequestDeserializer(ObjectDeserializer op) { - + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::repository, Repository._DESERIALIZER, "repository"); op.add(Builder::settings, RepositorySettings._DESERIALIZER, "settings"); op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - } // --------------------------------------------------------------------------------------------- @@ -380,52 +453,63 @@ protected static void setupCreateRepositoryRequestDeserializer(ObjectDeserialize * Endpoint "{@code snapshot.create_repository}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "PUT"; - - }, - + request -> "PUT", // 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); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_snapshot/"); + SimpleEndpoint.pathEncode(request.name, buf); + return buf.toString(); }, - // Request parameters request -> { Map 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.verify != null) { - params.put("verify", String.valueOf(request.verify)); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } + if (request.verify != null) { + params.put("verify", String.valueOf(request.verify)); + } return params; - }, SimpleEndpoint.emptyMap(), true, CreateRepositoryResponse._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.repository); + result = 31 * result + this.settings.hashCode(); + result = 31 * result + Objects.hashCode(this.timeout); + result = 31 * result + this.type.hashCode(); + result = 31 * result + Objects.hashCode(this.verify); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + CreateRepositoryRequest other = (CreateRepositoryRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && this.name.equals(other.name) + && Objects.equals(this.repository, other.repository) + && this.settings.equals(other.settings) + && Objects.equals(this.timeout, other.timeout) + && this.type.equals(other.type) + && Objects.equals(this.verify, other.verify); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryResponse.java similarity index 63% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryResponse.java index 33b2585dde..9a9be3e5c8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryResponse.java @@ -30,41 +30,80 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.snapshot; import java.util.function.Function; +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.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.opensearch._types.AcknowledgedResponseBase; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: snapshot.create_repository.Response @JsonpDeserializable -public class CreateRepositoryResponse extends AcknowledgedResponseBase { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class CreateRepositoryResponse extends AcknowledgedResponseBase + implements + ToCopyableBuilder { + // --------------------------------------------------------------------------------------------- private CreateRepositoryResponse(Builder builder) { super(builder); - } - public static CreateRepositoryResponse of(Function> fn) { + public static CreateRepositoryResponse of(Function> fn) { return fn.apply(new Builder()).build(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link CreateRepositoryResponse}. */ - public static class Builder extends AcknowledgedResponseBase.AbstractBuilder implements - ObjectBuilder { + CopyableBuilder { + + public Builder() {} + + private Builder(CreateRepositoryResponse o) { + super(o); + } + + private Builder(Builder o) { + super(o); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + @Override + @Nonnull protected Builder self() { return this; } @@ -72,9 +111,10 @@ protected Builder self() { /** * Builds a {@link CreateRepositoryResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public CreateRepositoryResponse build() { _checkSingleUse(); @@ -93,8 +133,22 @@ public CreateRepositoryResponse build() { ); protected static void setupCreateRepositoryResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); + setupAcknowledgedResponseBaseDeserializer(op); + } + @Override + public int hashCode() { + int result = super.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryRequest.java similarity index 65% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryRequest.java index bc42a3d20a..66f0aa35e4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryRequest.java @@ -30,13 +30,19 @@ * 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.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; -import java.util.stream.Collectors; +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; @@ -44,24 +50,29 @@ 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_repository.Request /** * Deletes a repository. - * */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class DeleteRepositoryRequest extends RequestBase + implements + ToCopyableBuilder { -public class DeleteRepositoryRequest 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 List name; @Nullable @@ -70,44 +81,46 @@ public class DeleteRepositoryRequest extends RequestBase { // --------------------------------------------------------------------------------------------- private DeleteRepositoryRequest(Builder builder) { - - this.masterTimeout = builder.masterTimeout; this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.masterTimeout = builder.masterTimeout; this.name = ApiTypeHelper.unmodifiableRequired(builder.name, this, "name"); this.timeout = builder.timeout; - } - public static DeleteRepositoryRequest of(Function> fn) { + public static DeleteRepositoryRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Explicit operation timeout for connection to master node + * Operation timeout for connection to cluster-manager node. *

- * API name: {@code master_timeout} + * API name: {@code cluster_manager_timeout} + *

*/ @Nullable - public final Time masterTimeout() { - return this.masterTimeout; + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; } /** * Explicit operation timeout for connection to cluster-manager node *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ + @Deprecated @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; + public final Time masterTimeout() { + return this.masterTimeout; } /** - * Required - Name of the snapshot repository to unregister. Wildcard - * (*) patterns are supported. + * Required - Name of the snapshot repository to unregister. Wildcard (*) patterns are supported. *

* API name: {@code repository} + *

*/ + @Nonnull public final List name() { return this.name; } @@ -116,6 +129,7 @@ public final List name() { * Explicit operation timeout *

* API name: {@code timeout} + *

*/ @Nullable public final Time timeout() { @@ -124,84 +138,126 @@ public final Time timeout() { // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link DeleteRepositoryRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Deprecated - @Nullable - private Time masterTimeout; - + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private Time clusterManagerTimeout; - + @Nullable + private Time masterTimeout; private List name; - @Nullable private Time timeout; + public Builder() {} + + private Builder(DeleteRepositoryRequest o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.masterTimeout = o.masterTimeout; + this.name = _listCopy(o.name); + this.timeout = o.timeout; + } + + private Builder(Builder o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.masterTimeout = o.masterTimeout; + this.name = _listCopy(o.name); + this.timeout = o.timeout; + } + + @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. *

- * API name: {@code master_timeout} + * API name: {@code cluster_manager_timeout} + *

*/ - @Deprecated - 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. *

- * API name: {@code master_timeout} + * API name: {@code cluster_manager_timeout} + *

*/ - @Deprecated - public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); + @Nonnull + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); } /** * Explicit operation timeout for connection to cluster-manager node *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ - 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 *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + @Deprecated + @Nonnull + public final Builder masterTimeout(Function> fn) { + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** - * Required - Name of the snapshot repository to unregister. Wildcard - * (*) patterns are supported. + * Required - Name of the snapshot repository to unregister. Wildcard (*) patterns are supported. *

* API name: {@code repository} + *

+ * *

* Adds all elements of list to name. + *

*/ + @Nonnull public final Builder name(List list) { this.name = _listAddAll(this.name, list); return this; } /** - * Required - Name of the snapshot repository to unregister. Wildcard - * (*) patterns are supported. + * Required - Name of the snapshot repository to unregister. Wildcard (*) patterns are supported. *

* API name: {@code repository} + *

+ * *

* Adds one or more values to name. + *

*/ + @Nonnull public final Builder name(String value, String... values) { this.name = _listAdd(this.name, value, values); return this; @@ -211,7 +267,9 @@ public final Builder name(String value, String... values) { * Explicit operation timeout *

* API name: {@code timeout} + *

*/ + @Nonnull public final Builder timeout(@Nullable Time value) { this.timeout = value; return this; @@ -221,17 +279,20 @@ public final Builder timeout(@Nullable Time value) { * Explicit operation timeout *

* API name: {@code timeout} + *

*/ + @Nonnull public final Builder timeout(Function> fn) { - return this.timeout(fn.apply(new Time.Builder()).build()); + return timeout(fn.apply(new Time.Builder()).build()); } /** * Builds a {@link DeleteRepositoryRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public DeleteRepositoryRequest build() { _checkSingleUse(); @@ -245,49 +306,52 @@ public DeleteRepositoryRequest build() { * Endpoint "{@code snapshot.delete_repository}". */ public static final Endpoint _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("/_snapshot"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name.stream().map(v -> v).collect(Collectors.joining(",")), buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_snapshot/"); + SimpleEndpoint.pathEncode(String.join(",", request.name), buf); + return buf.toString(); }, - // Request parameters request -> { Map 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, DeleteRepositoryResponse._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; + DeleteRepositoryRequest other = (DeleteRepositoryRequest) 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); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryResponse.java similarity index 63% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryResponse.java index 78541abe80..f1709184ed 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteRepositoryResponse.java @@ -30,41 +30,80 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.snapshot; import java.util.function.Function; +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.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.opensearch._types.AcknowledgedResponseBase; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: snapshot.delete_repository.Response @JsonpDeserializable -public class DeleteRepositoryResponse extends AcknowledgedResponseBase { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class DeleteRepositoryResponse extends AcknowledgedResponseBase + implements + ToCopyableBuilder { + // --------------------------------------------------------------------------------------------- private DeleteRepositoryResponse(Builder builder) { super(builder); - } - public static DeleteRepositoryResponse of(Function> fn) { + public static DeleteRepositoryResponse of(Function> fn) { return fn.apply(new Builder()).build(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link DeleteRepositoryResponse}. */ - public static class Builder extends AcknowledgedResponseBase.AbstractBuilder implements - ObjectBuilder { + CopyableBuilder { + + public Builder() {} + + private Builder(DeleteRepositoryResponse o) { + super(o); + } + + private Builder(Builder o) { + super(o); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + @Override + @Nonnull protected Builder self() { return this; } @@ -72,9 +111,10 @@ protected Builder self() { /** * Builds a {@link DeleteRepositoryResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public DeleteRepositoryResponse build() { _checkSingleUse(); @@ -93,8 +133,22 @@ public DeleteRepositoryResponse build() { ); protected static void setupDeleteRepositoryResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); + setupAcknowledgedResponseBaseDeserializer(op); + } + @Override + public int hashCode() { + int result = super.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetRepositoryRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetRepositoryRequest.java similarity index 68% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetRepositoryRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetRepositoryRequest.java index fb8e7c8de5..31e8b5aaf1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetRepositoryRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetRepositoryRequest.java @@ -30,13 +30,19 @@ * 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.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; -import java.util.stream.Collectors; +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; @@ -44,16 +50,22 @@ 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.get_repository.Request /** * Returns information about a repository. */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class GetRepositoryRequest extends RequestBase implements ToCopyableBuilder { + + @Nullable + private final Time clusterManagerTimeout; -public class GetRepositoryRequest extends RequestBase { @Nullable private final Boolean local; @@ -61,145 +73,186 @@ public class GetRepositoryRequest extends RequestBase { @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - + @Nonnull private final List name; // --------------------------------------------------------------------------------------------- private GetRepositoryRequest(Builder builder) { - + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.local = builder.local; this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.name = ApiTypeHelper.unmodifiable(builder.name); - } - public static GetRepositoryRequest of(Function> fn) { + public static GetRepositoryRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Return local information, do not retrieve the state from cluster-manager node - * (default: false) + * Operation timeout for connection to cluster-manager node. *

- * API name: {@code local} + * API name: {@code cluster_manager_timeout} + *

*/ @Nullable - public final Boolean local() { - return this.local; + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; } /** - * Explicit operation timeout for connection to master node + * Return local information, do not retrieve the state from cluster-manager node. *

- * API name: {@code master_timeout} + * API name: {@code local} + *

*/ - @Deprecated @Nullable - public final Time masterTimeout() { - return this.masterTimeout; + public final Boolean local() { + return this.local; } /** * Explicit operation timeout for connection to cluster-manager node *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ + @Deprecated @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; + public final Time masterTimeout() { + return this.masterTimeout; } /** * A comma-separated list of repository names *

* API name: {@code repository} + *

*/ + @Nonnull public final List name() { return this.name; } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link GetRepositoryRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private Time clusterManagerTimeout; @Nullable private Boolean local; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - @Nullable private List name; + public Builder() {} + + private Builder(GetRepositoryRequest o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.local = o.local; + this.masterTimeout = o.masterTimeout; + this.name = _listCopy(o.name); + } + + private Builder(Builder o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.local = o.local; + this.masterTimeout = o.masterTimeout; + this.name = _listCopy(o.name); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** - * Return local information, do not retrieve the state from cluster-manager node - * (default: false) + * Operation timeout for connection to cluster-manager node. *

- * API name: {@code local} + * API name: {@code cluster_manager_timeout} + *

*/ - public final Builder local(@Nullable Boolean value) { - this.local = 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. *

- * API name: {@code master_timeout} + * API name: {@code cluster_manager_timeout} + *

*/ - @Deprecated - public final Builder masterTimeout(@Nullable Time value) { - this.masterTimeout = value; - return this; + @Nonnull + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); } /** - * Explicit operation timeout for connection to master node + * Return local information, do not retrieve the state from cluster-manager node. *

- * API name: {@code master_timeout} + * API name: {@code local} + *

*/ - @Deprecated - public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); + @Nonnull + public final Builder local(@Nullable Boolean value) { + this.local = value; + return this; } /** * Explicit operation timeout for connection to cluster-manager node *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ - 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 *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + @Deprecated + @Nonnull + public final Builder masterTimeout(Function> fn) { + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** * A comma-separated list of repository names *

* API name: {@code repository} + *

+ * *

* Adds all elements of list to name. + *

*/ + @Nonnull public final Builder name(List list) { this.name = _listAddAll(this.name, list); return this; @@ -209,9 +262,13 @@ public final Builder name(List list) { * A comma-separated list of repository names *

* API name: {@code repository} + *

+ * *

* Adds one or more values to name. + *

*/ + @Nonnull public final Builder name(String value, String... values) { this.name = _listAdd(this.name, value, values); return this; @@ -220,9 +277,10 @@ public final Builder name(String value, String... values) { /** * Builds a {@link GetRepositoryRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public GetRepositoryRequest build() { _checkSingleUse(); @@ -236,13 +294,8 @@ public GetRepositoryRequest build() { * Endpoint "{@code snapshot.get_repository}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // Request path request -> { final int _name = 1 << 0; @@ -252,38 +305,54 @@ public GetRepositoryRequest build() { if (ApiTypeHelper.isDefined(request.name())) propsSet |= _name; if (propsSet == 0) { - StringBuilder buf = new StringBuilder(); - buf.append("/_snapshot"); - return buf.toString(); + return "/_snapshot"; } if (propsSet == (_name)) { StringBuilder buf = new StringBuilder(); - buf.append("/_snapshot"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name.stream().map(v -> v).collect(Collectors.joining(",")), buf); + buf.append("/_snapshot/"); + SimpleEndpoint.pathEncode(String.join(",", request.name), buf); return buf.toString(); } - throw SimpleEndpoint.noPathTemplateFound("path"); + throw SimpleEndpoint.noPathTemplateFound("path"); }, - // Request parameters request -> { Map 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.local != null) { params.put("local", String.valueOf(request.local)); } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } return params; - }, SimpleEndpoint.emptyMap(), false, GetRepositoryResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.local); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + Objects.hashCode(this.name); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + GetRepositoryRequest other = (GetRepositoryRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.local, other.local) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.name, other.name); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetRepositoryResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetRepositoryResponse.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetRepositoryResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetRepositoryResponse.java index 1ee954697c..e3f7d77ea6 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetRepositoryResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetRepositoryResponse.java @@ -30,9 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.snapshot; import java.util.function.Function; +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.ObjectBuilderDeserializer; @@ -43,15 +49,15 @@ // typedef: snapshot.get_repository.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetRepositoryResponse extends DictionaryResponse { // --------------------------------------------------------------------------------------------- private GetRepositoryResponse(Builder builder) { super(builder); - } - public static GetRepositoryResponse of(Function> fn) { + public static GetRepositoryResponse of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -60,11 +66,11 @@ public static GetRepositoryResponse of(Function implements ObjectBuilder { @Override + @Nonnull protected Builder self() { return this; } @@ -72,8 +78,7 @@ protected Builder self() { /** * Builds a {@link GetRepositoryResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public GetRepositoryResponse build() { _checkSingleUse(); @@ -95,8 +100,6 @@ public GetRepositoryResponse build() { ); protected static void setupGetRepositoryResponseDeserializer(ObjectDeserializer op) { - DictionaryResponse.setupDictionaryResponseDeserializer(op, JsonpDeserializer.stringDeserializer(), Repository._DESERIALIZER); - + setupDictionaryResponseDeserializer(op, JsonpDeserializer.stringDeserializer(), Repository._DESERIALIZER); } - } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java index 615f8a5882..a473778254 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java @@ -119,6 +119,48 @@ public final CompletableFuture create( return create(fn.apply(new CreateSnapshotRequest.Builder()).build()); } + // ----- Endpoint: snapshot.create_repository + + /** + * Creates a repository. + */ + public CompletableFuture createRepository(CreateRepositoryRequest request) throws IOException, + OpenSearchException { + return this.transport.performRequestAsync(request, CreateRepositoryRequest._ENDPOINT, this.transportOptions); + } + + /** + * Creates a repository. + * + * @param fn a function that initializes a builder to create the {@link CreateRepositoryRequest} + */ + public final CompletableFuture createRepository( + Function> fn + ) throws IOException, OpenSearchException { + return createRepository(fn.apply(new CreateRepositoryRequest.Builder()).build()); + } + + // ----- Endpoint: snapshot.delete_repository + + /** + * Deletes a repository. + */ + public CompletableFuture deleteRepository(DeleteRepositoryRequest request) throws IOException, + OpenSearchException { + return this.transport.performRequestAsync(request, DeleteRepositoryRequest._ENDPOINT, this.transportOptions); + } + + /** + * Deletes a repository. + * + * @param fn a function that initializes a builder to create the {@link DeleteRepositoryRequest} + */ + public final CompletableFuture deleteRepository( + Function> fn + ) throws IOException, OpenSearchException { + return deleteRepository(fn.apply(new DeleteRepositoryRequest.Builder()).build()); + } + // ----- Endpoint: snapshot.get /** @@ -138,6 +180,33 @@ public final CompletableFuture get(Function getRepository(GetRepositoryRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, GetRepositoryRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about a repository. + * + * @param fn a function that initializes a builder to create the {@link GetRepositoryRequest} + */ + public final CompletableFuture getRepository( + Function> fn + ) throws IOException, OpenSearchException { + return getRepository(fn.apply(new GetRepositoryRequest.Builder()).build()); + } + + /** + * Returns information about a repository. + */ + public final CompletableFuture getRepository() throws IOException, OpenSearchException { + return getRepository(new GetRepositoryRequest.Builder().build()); + } + // ----- Endpoint: snapshot.verify_repository /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java index 84844ee8cb..537152424d 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java @@ -115,6 +115,46 @@ public final CreateSnapshotResponse create(Function> fn + ) throws IOException, OpenSearchException { + return createRepository(fn.apply(new CreateRepositoryRequest.Builder()).build()); + } + + // ----- Endpoint: snapshot.delete_repository + + /** + * Deletes a repository. + */ + public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, DeleteRepositoryRequest._ENDPOINT, this.transportOptions); + } + + /** + * Deletes a repository. + * + * @param fn a function that initializes a builder to create the {@link DeleteRepositoryRequest} + */ + public final DeleteRepositoryResponse deleteRepository( + Function> fn + ) throws IOException, OpenSearchException { + return deleteRepository(fn.apply(new DeleteRepositoryRequest.Builder()).build()); + } + // ----- Endpoint: snapshot.get /** @@ -134,6 +174,32 @@ public final GetSnapshotResponse get(Function> fn) + throws IOException, OpenSearchException { + return getRepository(fn.apply(new GetRepositoryRequest.Builder()).build()); + } + + /** + * Returns information about a repository. + */ + public final GetRepositoryResponse getRepository() throws IOException, OpenSearchException { + return getRepository(new GetRepositoryRequest.Builder().build()); + } + // ----- Endpoint: snapshot.verify_repository /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/Repository.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/Repository.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/Repository.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/Repository.java index a74628a5fb..91665ef306 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/Repository.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/Repository.java @@ -30,10 +30,17 @@ * 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.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -42,37 +49,50 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; 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._types.Repository +// typedef: snapshot.Repository @JsonpDeserializable -public class Repository implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class Repository implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull + private final RepositorySettings settings; + + @Nonnull private final String type; @Nullable private final String uuid; - private final RepositorySettings settings; - // --------------------------------------------------------------------------------------------- private Repository(Builder builder) { - + this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); this.uuid = builder.uuid; - this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); - } - public static Repository of(Function> fn) { + public static Repository of(Function> fn) { return fn.apply(new Builder()).build(); } + /** + * Required - API name: {@code settings} + */ + @Nonnull + public final RepositorySettings settings() { + return this.settings; + } + /** * Required - API name: {@code type} */ + @Nonnull public final String type() { return this.type; } @@ -85,16 +105,10 @@ public final String uuid() { return this.uuid; } - /** - * Required - API name: {@code settings} - */ - public final RepositorySettings settings() { - return this.settings; - } - /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -102,6 +116,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); generator.writeKey("type"); generator.write(this.type); @@ -109,46 +125,55 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (this.uuid != null) { generator.writeKey("uuid"); generator.write(this.uuid); - } - generator.writeKey("settings"); - this.settings.serialize(generator, mapper); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link Repository}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + private RepositorySettings settings; private String type; - @Nullable private String uuid; - private RepositorySettings settings; + public Builder() {} - /** - * Required - API name: {@code type} - */ - public final Builder type(String value) { - this.type = value; - return this; + private Builder(Repository o) { + this.settings = o.settings; + this.type = o.type; + this.uuid = o.uuid; } - /** - * API name: {@code uuid} - */ - public final Builder uuid(@Nullable String value) { - this.uuid = value; - return this; + private Builder(Builder o) { + this.settings = o.settings; + this.type = o.type; + this.uuid = o.uuid; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); } /** * Required - API name: {@code settings} */ + @Nonnull public final Builder settings(RepositorySettings value) { this.settings = value; return this; @@ -157,16 +182,36 @@ public final Builder settings(RepositorySettings value) { /** * Required - API name: {@code settings} */ + @Nonnull public final Builder settings(Function> fn) { - return this.settings(fn.apply(new RepositorySettings.Builder()).build()); + return settings(fn.apply(new RepositorySettings.Builder()).build()); + } + + /** + * Required - API name: {@code type} + */ + @Nonnull + public final Builder type(String value) { + this.type = value; + return this; + } + + /** + * API name: {@code uuid} + */ + @Nonnull + public final Builder uuid(@Nullable String value) { + this.uuid = value; + return this; } /** * Builds a {@link Repository}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public Repository build() { _checkSingleUse(); @@ -185,11 +230,25 @@ public Repository build() { ); protected static void setupRepositoryDeserializer(ObjectDeserializer op) { - + op.add(Builder::settings, RepositorySettings._DESERIALIZER, "settings"); op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); op.add(Builder::uuid, JsonpDeserializer.stringDeserializer(), "uuid"); - op.add(Builder::settings, RepositorySettings._DESERIALIZER, "settings"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.settings.hashCode(); + result = 31 * result + this.type.hashCode(); + result = 31 * result + Objects.hashCode(this.uuid); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + Repository other = (Repository) o; + return this.settings.equals(other.settings) && this.type.equals(other.type) && Objects.equals(this.uuid, other.uuid); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/RepositorySettings.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RepositorySettings.java similarity index 68% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/RepositorySettings.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RepositorySettings.java index 601a2de702..1c32397b47 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/RepositorySettings.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RepositorySettings.java @@ -30,10 +30,17 @@ * 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.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -42,13 +49,17 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; 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._types.RepositorySettings +// typedef: snapshot.RepositorySettings @JsonpDeserializable -public class RepositorySettings implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class RepositorySettings implements PlainJsonSerializable, ToCopyableBuilder { + @Nullable private final String chunkSize; @@ -56,8 +67,9 @@ public class RepositorySettings implements PlainJsonSerializable { private final Boolean compress; @Nullable - private final String concurrentStreams; + private final Integer concurrentStreams; + @Nonnull private final String location; @Nullable @@ -66,16 +78,14 @@ public class RepositorySettings implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private RepositorySettings(Builder builder) { - this.chunkSize = builder.chunkSize; this.compress = builder.compress; this.concurrentStreams = builder.concurrentStreams; this.location = ApiTypeHelper.requireNonNull(builder.location, this, "location"); this.readOnly = builder.readOnly; - } - public static RepositorySettings of(Function> fn) { + public static RepositorySettings of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -99,13 +109,14 @@ public final Boolean compress() { * API name: {@code concurrent_streams} */ @Nullable - public final String concurrentStreams() { + public final Integer concurrentStreams() { return this.concurrentStreams; } /** * Required - API name: {@code location} */ + @Nonnull public final String location() { return this.location; } @@ -121,6 +132,7 @@ public final Boolean readOnly() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -128,57 +140,85 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.chunkSize != null) { generator.writeKey("chunk_size"); generator.write(this.chunkSize); - } + if (this.compress != null) { generator.writeKey("compress"); generator.write(this.compress); - } + if (this.concurrentStreams != null) { generator.writeKey("concurrent_streams"); generator.write(this.concurrentStreams); - } + generator.writeKey("location"); generator.write(this.location); if (this.readOnly != null) { generator.writeKey("read_only"); generator.write(this.readOnly); - } - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link RepositorySettings}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private String chunkSize; - @Nullable private Boolean compress; - @Nullable - private String concurrentStreams; - + private Integer concurrentStreams; private String location; - @Nullable private Boolean readOnly; + public Builder() {} + + private Builder(RepositorySettings o) { + this.chunkSize = o.chunkSize; + this.compress = o.compress; + this.concurrentStreams = o.concurrentStreams; + this.location = o.location; + this.readOnly = o.readOnly; + } + + private Builder(Builder o) { + this.chunkSize = o.chunkSize; + this.compress = o.compress; + this.concurrentStreams = o.concurrentStreams; + this.location = o.location; + this.readOnly = o.readOnly; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * API name: {@code chunk_size} */ + @Nonnull public final Builder chunkSize(@Nullable String value) { this.chunkSize = value; return this; @@ -187,6 +227,7 @@ public final Builder chunkSize(@Nullable String value) { /** * API name: {@code compress} */ + @Nonnull public final Builder compress(@Nullable Boolean value) { this.compress = value; return this; @@ -195,7 +236,8 @@ public final Builder compress(@Nullable Boolean value) { /** * API name: {@code concurrent_streams} */ - public final Builder concurrentStreams(@Nullable String value) { + @Nonnull + public final Builder concurrentStreams(@Nullable Integer value) { this.concurrentStreams = value; return this; } @@ -203,6 +245,7 @@ public final Builder concurrentStreams(@Nullable String value) { /** * Required - API name: {@code location} */ + @Nonnull public final Builder location(String value) { this.location = value; return this; @@ -211,6 +254,7 @@ public final Builder location(String value) { /** * API name: {@code read_only} */ + @Nonnull public final Builder readOnly(@Nullable Boolean value) { this.readOnly = value; return this; @@ -219,9 +263,10 @@ public final Builder readOnly(@Nullable Boolean value) { /** * Builds a {@link RepositorySettings}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public RepositorySettings build() { _checkSingleUse(); @@ -240,13 +285,33 @@ public RepositorySettings build() { ); protected static void setupRepositorySettingsDeserializer(ObjectDeserializer op) { - op.add(Builder::chunkSize, JsonpDeserializer.stringDeserializer(), "chunk_size"); op.add(Builder::compress, JsonpDeserializer.booleanDeserializer(), "compress"); - op.add(Builder::concurrentStreams, JsonpDeserializer.stringDeserializer(), "concurrent_streams"); + op.add(Builder::concurrentStreams, JsonpDeserializer.integerDeserializer(), "concurrent_streams"); op.add(Builder::location, JsonpDeserializer.stringDeserializer(), "location"); - op.add(Builder::readOnly, JsonpDeserializer.booleanDeserializer(), "read_only", "readonly"); + op.add(Builder::readOnly, JsonpDeserializer.booleanDeserializer(), "read_only"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.chunkSize); + result = 31 * result + Objects.hashCode(this.compress); + result = 31 * result + Objects.hashCode(this.concurrentStreams); + result = 31 * result + this.location.hashCode(); + result = 31 * result + Objects.hashCode(this.readOnly); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + RepositorySettings other = (RepositorySettings) o; + return Objects.equals(this.chunkSize, other.chunkSize) + && Objects.equals(this.compress, other.compress) + && Objects.equals(this.concurrentStreams, other.concurrentStreams) + && this.location.equals(other.location) + && Objects.equals(this.readOnly, other.readOnly); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java index 86e3016d6b..d73e7d5c97 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java @@ -79,40 +79,6 @@ public CompletableFuture create(CreateSnapshotRequest re return this.transport.performRequestAsync(request, endpoint, this.transportOptions); } - // ----- Endpoint: snapshot.create_repository - - /** - * Creates a repository. - * - * - */ - - public CompletableFuture createRepository(CreateRepositoryRequest request) throws IOException, - OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - CreateRepositoryRequest, - CreateRepositoryResponse, - ErrorResponse>) CreateRepositoryRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates a repository. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateRepositoryRequest} - * - */ - - public final CompletableFuture createRepository( - Function> fn - ) throws IOException, OpenSearchException { - return createRepository(fn.apply(new CreateRepositoryRequest.Builder()).build()); - } - // ----- Endpoint: snapshot.delete /** @@ -146,87 +112,6 @@ public final CompletableFuture delete( return delete(fn.apply(new DeleteSnapshotRequest.Builder()).build()); } - // ----- Endpoint: snapshot.delete_repository - - /** - * Deletes a repository. - * - * - */ - - public CompletableFuture deleteRepository(DeleteRepositoryRequest request) throws IOException, - OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteRepositoryRequest, - DeleteRepositoryResponse, - ErrorResponse>) DeleteRepositoryRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Deletes a repository. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteRepositoryRequest} - * - */ - - public final CompletableFuture deleteRepository( - Function> fn - ) throws IOException, OpenSearchException { - return deleteRepository(fn.apply(new DeleteRepositoryRequest.Builder()).build()); - } - - // ----- Endpoint: snapshot.get_repository - - /** - * Returns information about a repository. - * - * - */ - - public CompletableFuture getRepository(GetRepositoryRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetRepositoryRequest, - GetRepositoryResponse, - ErrorResponse>) GetRepositoryRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about a repository. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetRepositoryRequest} - * - */ - - public final CompletableFuture getRepository( - Function> fn - ) throws IOException, OpenSearchException { - return getRepository(fn.apply(new GetRepositoryRequest.Builder()).build()); - } - - /** - * Returns information about a repository. - * - * - */ - - public CompletableFuture getRepository() throws IOException, OpenSearchException { - return this.transport.performRequestAsync( - new GetRepositoryRequest.Builder().build(), - GetRepositoryRequest._ENDPOINT, - this.transportOptions - ); - } - // ----- Endpoint: snapshot.restore /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java index e80cf77ee8..dda8c56e95 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java @@ -78,39 +78,6 @@ public CreateSnapshotResponse create(CreateSnapshotRequest request) throws IOExc return this.transport.performRequest(request, endpoint, this.transportOptions); } - // ----- Endpoint: snapshot.create_repository - - /** - * Creates a repository. - * - * - */ - - public CreateRepositoryResponse createRepository(CreateRepositoryRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - CreateRepositoryRequest, - CreateRepositoryResponse, - ErrorResponse>) CreateRepositoryRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates a repository. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateRepositoryRequest} - * - */ - - public final CreateRepositoryResponse createRepository( - Function> fn - ) throws IOException, OpenSearchException { - return createRepository(fn.apply(new CreateRepositoryRequest.Builder()).build()); - } - // ----- Endpoint: snapshot.delete /** @@ -143,85 +110,6 @@ public final DeleteSnapshotResponse delete(Function endpoint = (JsonEndpoint< - DeleteRepositoryRequest, - DeleteRepositoryResponse, - ErrorResponse>) DeleteRepositoryRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Deletes a repository. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteRepositoryRequest} - * - */ - - public final DeleteRepositoryResponse deleteRepository( - Function> fn - ) throws IOException, OpenSearchException { - return deleteRepository(fn.apply(new DeleteRepositoryRequest.Builder()).build()); - } - - // ----- Endpoint: snapshot.get_repository - - /** - * Returns information about a repository. - * - * - */ - - public GetRepositoryResponse getRepository(GetRepositoryRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetRepositoryRequest, - GetRepositoryResponse, - ErrorResponse>) GetRepositoryRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about a repository. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetRepositoryRequest} - * - */ - - public final GetRepositoryResponse getRepository(Function> fn) - throws IOException, OpenSearchException { - return getRepository(fn.apply(new GetRepositoryRequest.Builder()).build()); - } - - /** - * Returns information about a repository. - * - * - */ - - public GetRepositoryResponse getRepository() throws IOException, OpenSearchException { - return this.transport.performRequest( - new GetRepositoryRequest.Builder().build(), - GetRepositoryRequest._ENDPOINT, - this.transportOptions - ); - } - // ----- Endpoint: snapshot.restore /** diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index f21d3aa555..64b87dc3bd 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -53466,7 +53466,7 @@ components: type: boolean model_index_status: oneOf: - - $ref: '#/components/schemas/_common___HealthStatusCapitalized' + - $ref: '#/components/schemas/_common___HealthStatus' - type: 'null' nodes: type: object @@ -58620,19 +58620,13 @@ components: chunk_size: type: string compress: - oneOf: - - type: string - - type: boolean + $ref: '#/components/schemas/_common___StringifiedBoolean' concurrent_streams: - oneOf: - - type: string - - type: number + $ref: '#/components/schemas/_common___StringifiedInteger' location: type: string read_only: - oneOf: - - type: string - - type: boolean + $ref: '#/components/schemas/_common___StringifiedBoolean' required: - location snapshot._common___ShardsStats: diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java index cfbd41466e..beaaea57a0 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java @@ -68,7 +68,7 @@ public class CodeGenerator { isNot("search_models") ) ), - and(namespace(is("snapshot")), name(isOneOf("cleanup_repository", "clone", "create", "get", "verify_repository"))), + and(namespace(is("snapshot")), name(or(contains("repository"), isOneOf("clone", "create", "get")))), and(namespace(is("tasks"))) ); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index c806b31fee..8e750f8fec 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -16,6 +16,7 @@ import java.util.Objects; import java.util.Set; import java.util.TreeMap; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; @@ -103,7 +104,13 @@ public boolean canBeSingleton() { @Override public Collection getFieldsToDeserialize() { var fields = new TreeMap<>(bodyFields); - fields.putAll(pathParams); + var wireNameSet = bodyFields.values().stream().map(Field::getWireName).collect(Collectors.toSet()); + pathParams.forEach((k, v) -> { + if (wireNameSet.contains(v.getWireName())) { + v = v.toBuilder().withWireName(v.getName()).build(); + } + fields.put(k, v); + }); return fields.values(); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java index d0116d6178..49a3fc34e2 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java @@ -27,6 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.client.codegen.model.overrides.Overrides; +import org.opensearch.client.codegen.model.overrides.PathParameterOverride; import org.opensearch.client.codegen.model.overrides.PropertyOverride; import org.opensearch.client.codegen.model.overrides.SchemaOverride; import org.opensearch.client.codegen.model.overrides.ShouldGenerate; @@ -149,6 +150,7 @@ private void visit(@Nonnull OperationGroup group, @Nonnull List variants) { + var overrides = this.overrides.getOperation(group); var seenHttpPaths = new HashSet(); HashSet requiredPathParams = null; var allPathParams = new HashMap(); @@ -170,7 +172,10 @@ private RequestShape visit(@Nonnull Namespace parent, @Nonnull OperationGroup gr variant.getAllRelevantParameters(In.Path).forEach(parameter -> { var paramName = parameter.getName().orElseThrow(); if (!allPathParams.containsKey(paramName)) { - allPathParams.put(paramName, visit(parameter)); + var paramOverrides = overrides.flatMap(o -> o.getPathParameter(paramName)); + var paramBuilder = visit(parameter).toBuilder(); + paramOverrides.flatMap(PathParameterOverride::getName).ifPresent(paramBuilder::withName); + allPathParams.put(paramName, paramBuilder.build()); } }); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/OperationOverride.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/OperationOverride.java new file mode 100644 index 0000000000..c83c0fe235 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/OperationOverride.java @@ -0,0 +1,76 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.model.overrides; + +import java.util.Collections; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Function; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.opensearch.client.codegen.model.OperationGroup; +import org.opensearch.client.codegen.utils.builder.ObjectBuilder; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectMapBuilderBase; + +public final class OperationOverride { + @Nonnull + private final Map pathParameters; + + private OperationOverride(Builder builder) { + this.pathParameters = builder.pathParameters != null ? builder.pathParameters : Collections.emptyMap(); + } + + @Nonnull + public Optional getPathParameter(@Nonnull String key) { + return Optional.ofNullable(pathParameters.get(key)); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + + @Nonnull + public static MapBuilder mapBuilder() { + return new MapBuilder(); + } + + public static final class Builder extends ObjectBuilderBase { + @Nullable + private Map pathParameters; + + private Builder() {} + + @Nonnull + @Override + protected OperationOverride construct() { + return new OperationOverride(this); + } + + @Nonnull + public Builder withPathParameters( + @Nonnull Function>> fn + ) { + this.pathParameters = Objects.requireNonNull(fn, "fn must not be null").apply(PathParameterOverride.mapBuilder()).build(); + return this; + } + } + + public static final class MapBuilder extends ObjectMapBuilderBase { + private MapBuilder() {} + + @Nonnull + @Override + protected Builder valueBuilder() { + return builder(); + } + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java index 99f90a1b82..81e66f4613 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java @@ -16,6 +16,7 @@ import java.util.function.Function; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.opensearch.client.codegen.model.OperationGroup; import org.opensearch.client.codegen.model.Types; import org.opensearch.client.codegen.openapi.JsonPointer; import org.opensearch.client.codegen.openapi.OpenApiSchema; @@ -27,86 +28,109 @@ private static JsonPointer schema(String namespace, String name) { return OpenApiSchema.COMPONENTS_SCHEMAS.append(namespace + OpenApiSchema.NAMESPACE_NAME_SEPARATOR + name); } - public static final Overrides OVERRIDES = builder().withSchemas( - s -> s.with(schema("_common", "Duration"), so -> so.withMappedType(Types.Client.OpenSearch._Types.Time)) - .with(schema("_common", "FieldValue"), so -> so.withMappedType(Types.Client.OpenSearch._Types.FieldValue)) - .with(schema("_common", "StringifiedBoolean"), so -> so.withMappedType(Types.Primitive.Boolean)) - .with(schema("_common", "StringifiedDouble"), so -> so.withMappedType(Types.Primitive.Double)) - .with(schema("_common", "StringifiedInteger"), so -> so.withMappedType(Types.Primitive.Int)) - .with(schema("_common", "StringifiedLong"), so -> so.withMappedType(Types.Primitive.Long)) - .with(schema("_common", "StringifiedEpochTimeUnitMillis"), so -> so.withMappedType(Types.Primitive.Long)) - - .with(schema("_common", "DistanceUnit"), so -> so.withShouldGenerate(ShouldGenerate.Always)) - .with(schema("_common", "GeoBounds"), so -> so.withShouldGenerate(ShouldGenerate.Always)) - .with(schema("_common", "GeoDistanceType"), so -> so.withShouldGenerate(ShouldGenerate.Always)) - .with(schema("_common", "GeoShapeRelation"), so -> so.withShouldGenerate(ShouldGenerate.Always)) - - .with(schema("_common", "ScriptSort"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + public static final Overrides OVERRIDES = builder().withOperations( + o -> o.with( + OperationGroup.from("snapshot.create_repository"), + oo -> oo.withPathParameters(pp -> pp.with("repository", po -> po.withName("name"))) + ) .with( - schema("_common", "SortOptions"), - so -> so.withMappedType(t -> t.withPackage(Types.Client.OpenSearch._Types.PACKAGE).withName("SortOptions")) + OperationGroup.from("snapshot.delete_repository"), + oo -> oo.withPathParameters(pp -> pp.with("repository", po -> po.withName("name"))) ) - - .with( - schema("_common.aggregations", "AggregationContainer"), - so -> so.withClassName("Aggregation").withShouldGenerate(ShouldGenerate.Never) - ) - - // TODO: Remove this once figuring out how best to handle these schemas - .with(schema("_common.query_dsl", "DecayFunction"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with( - schema("_common.query_dsl", "FunctionScoreContainer"), - so -> so.withShouldGenerate(ShouldGenerate.Never).withClassName("FunctionScore") - ) - .with(schema("_common.query_dsl", "DistanceFeatureQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "GeoBoundingBoxQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "GeoDistanceQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "GeoPolygonQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "GeoShapeQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "RangeQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "RankFeatureFunctionLinear"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "RankFeatureFunctionLogarithm"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "RankFeatureFunctionSaturation"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "RankFeatureFunctionSigmoid"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with( - schema("_common.query_dsl", "SpanGapQuery"), - so -> so.withMappedType(t -> t.withPackage(Types.Client.OpenSearch._Types.PACKAGE + ".query_dsl").withName("SpanGapQuery")) - ) - .with(schema("_common.query_dsl", "TermsQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - .with(schema("_common.query_dsl", "TermsQueryField"), so -> so.withShouldGenerate(ShouldGenerate.Always)) - .with(schema("_common.query_dsl", "XyShapeQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) - - .with(schema("_common.query_dsl", "FieldValueFactorModifier"), so -> so.withShouldGenerate(ShouldGenerate.Always)) - .with(schema("_common.query_dsl", "IntervalsContainer"), so -> so.withClassName("Intervals")) - - .with(schema("_common.query_dsl", "QueryBase"), so -> so.withProperties(p -> p.with("_name", po -> po.withName("queryName")))) - - .with(schema("_common.query_dsl", "QueryContainer"), so -> so.withClassName("Query")) - .with( - schema("_core.search", "SourceFilter").append("oneOf", "1"), - so -> so.withAliasProvider(k -> k.endsWith("cludes") ? Set.of(k.substring(0, k.length() - 1)) : null) + OperationGroup.from("snapshot.get_repository"), + oo -> oo.withPathParameters(pp -> pp.with("repository", po -> po.withName("name"))) ) + ) + .withSchemas( + s -> s.with(schema("_common", "Duration"), so -> so.withMappedType(Types.Client.OpenSearch._Types.Time)) + .with(schema("_common", "FieldValue"), so -> so.withMappedType(Types.Client.OpenSearch._Types.FieldValue)) + .with(schema("_common", "StringifiedBoolean"), so -> so.withMappedType(Types.Primitive.Boolean)) + .with(schema("_common", "StringifiedDouble"), so -> so.withMappedType(Types.Primitive.Double)) + .with(schema("_common", "StringifiedInteger"), so -> so.withMappedType(Types.Primitive.Int)) + .with(schema("_common", "StringifiedLong"), so -> so.withMappedType(Types.Primitive.Long)) + .with(schema("_common", "StringifiedEpochTimeUnitMillis"), so -> so.withMappedType(Types.Primitive.Long)) + + .with(schema("_common", "DistanceUnit"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + .with(schema("_common", "GeoBounds"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + .with(schema("_common", "GeoDistanceType"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + .with(schema("_common", "GeoShapeRelation"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + + .with(schema("_common", "ScriptSort"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + .with( + schema("_common", "SortOptions"), + so -> so.withMappedType(t -> t.withPackage(Types.Client.OpenSearch._Types.PACKAGE).withName("SortOptions")) + ) + + .with( + schema("_common.aggregations", "AggregationContainer"), + so -> so.withClassName("Aggregation").withShouldGenerate(ShouldGenerate.Never) + ) + + // TODO: Remove this once figuring out how best to handle these schemas + .with(schema("_common.query_dsl", "DecayFunction"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with( + schema("_common.query_dsl", "FunctionScoreContainer"), + so -> so.withShouldGenerate(ShouldGenerate.Never).withClassName("FunctionScore") + ) + .with(schema("_common.query_dsl", "DistanceFeatureQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "GeoBoundingBoxQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "GeoDistanceQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "GeoPolygonQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "GeoShapeQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "RangeQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "RankFeatureFunctionLinear"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "RankFeatureFunctionLogarithm"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "RankFeatureFunctionSaturation"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "RankFeatureFunctionSigmoid"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with( + schema("_common.query_dsl", "SpanGapQuery"), + so -> so.withMappedType( + t -> t.withPackage(Types.Client.OpenSearch._Types.PACKAGE + ".query_dsl").withName("SpanGapQuery") + ) + ) + .with(schema("_common.query_dsl", "TermsQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.query_dsl", "TermsQueryField"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + .with(schema("_common.query_dsl", "XyShapeQuery"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + + .with(schema("_common.query_dsl", "FieldValueFactorModifier"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + .with(schema("_common.query_dsl", "IntervalsContainer"), so -> so.withClassName("Intervals")) + + .with( + schema("_common.query_dsl", "QueryBase"), + so -> so.withProperties(p -> p.with("_name", po -> po.withName("queryName"))) + ) + + .with(schema("_common.query_dsl", "QueryContainer"), so -> so.withClassName("Query")) + + .with( + schema("_core.search", "SourceFilter").append("oneOf", "1"), + so -> so.withAliasProvider(k -> k.endsWith("cludes") ? Set.of(k.substring(0, k.length() - 1)) : null) + ) + + .with(schema("indices._common", "IndexSettings"), so -> so.withAliasProvider(k -> { + switch (k) { + case "index": + case "indexing": + case "mapping": + case "search": + case "settings": + case "top_metrics_max_size": + return null; + default: + return Set.of("index." + k); + } + })) + ) + .build(); - .with(schema("indices._common", "IndexSettings"), so -> so.withAliasProvider(k -> { - switch (k) { - case "index": - case "indexing": - case "mapping": - case "search": - case "settings": - case "top_metrics_max_size": - return null; - default: - return Set.of("index." + k); - } - })) - ).build(); - + @Nonnull + private final Map operations; @Nonnull private final Map schemas; private Overrides(Builder builder) { + this.operations = builder.operations != null ? Collections.unmodifiableMap(builder.operations) : Collections.emptyMap(); this.schemas = builder.schemas != null ? Collections.unmodifiableMap(builder.schemas) : Collections.emptyMap(); } @@ -120,12 +144,19 @@ public Optional getSchema(@Nonnull JsonPointer pointer) { return Optional.ofNullable(schemas.get(pointer)); } + @Nonnull + public Optional getOperation(@Nonnull OperationGroup group) { + return Optional.ofNullable(operations.get(group)); + } + @Nonnull public static Builder builder() { return new Builder(); } public static final class Builder extends ObjectBuilderBase { + @Nullable + private Map operations; @Nullable private Map schemas; @@ -137,6 +168,14 @@ protected Overrides construct() { return new Overrides(this); } + @Nonnull + public Builder withOperations( + @Nonnull Function>> fn + ) { + this.operations = Objects.requireNonNull(fn, "fn must not be null").apply(OperationOverride.mapBuilder()).build(); + return this; + } + @Nonnull public Builder withSchemas(@Nonnull Function>> fn) { this.schemas = Objects.requireNonNull(fn, "fn must not be null").apply(SchemaOverride.mapBuilder()).build(); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/PathParameterOverride.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/PathParameterOverride.java new file mode 100644 index 0000000000..6cd745217f --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/PathParameterOverride.java @@ -0,0 +1,68 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.model.overrides; + +import java.util.Optional; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectMapBuilderBase; + +public final class PathParameterOverride { + @Nullable + private final String name; + + private PathParameterOverride(Builder builder) { + this.name = builder.name; + } + + @Nonnull + public Optional getName() { + return Optional.ofNullable(name); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + + @Nonnull + public static MapBuilder mapBuilder() { + return new MapBuilder(); + } + + public static final class Builder extends ObjectBuilderBase { + @Nullable + private String name; + + private Builder() {} + + @Nonnull + @Override + protected PathParameterOverride construct() { + return new PathParameterOverride(this); + } + + @Nonnull + public Builder withName(@Nullable String value) { + this.name = value; + return this; + } + } + + public static final class MapBuilder extends ObjectMapBuilderBase { + private MapBuilder() {} + + @Nonnull + @Override + protected Builder valueBuilder() { + return builder(); + } + } +}