diff --git a/UPGRADING.md b/UPGRADING.md index f98573bf9c..1a782f2d94 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -160,4 +160,35 @@ 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`. + +### snapshot.RestoreRequest renamed to snapshot.RestoreSnapshotRequest +- The `snapshot.RestoreRequest` class has been renamed to `snapshot.RestoreSnapshotRequest`. +- The `indexSettings` property has been corrected to be of type `IndexSettings` instead of `PutIndicesSettingsRequest`. + +### snapshot.RestoreResponse renamed to snapshot.RestoreSnapshotResponse +- The `snapshot.RestoreResponse` class has been renamed to `snapshot.RestoreSnapshotResponse`. + +### snapshot.Status renamed to snapshot.SnapshotStatus +- The `snapshot.Status` class has been renamed to `snapshot.SnapshotStatus`, this affects: + - `snapshot.SnapshotStatusResponse`'s `snapshots` field. + +### snapshot.ShardStats renamed to snapshot.SnapshotShardStats +- The `snapshot.ShardStats` class has been renamed to `snapshot.SnapshotShardStats`, this affects: + - `snapshot.SnapshotStatus`'s (previous `snapshot.Status`) `shardsStats` field. + - `snapshot.SnapshotIndexStats`'s `shardsStats` field. + +### snapshot.ShardsStatsStage renamed to snapshot.SnapshotShardsStatsStage +- The `snapshot.ShardsStatsStage` class has been renamed to `snapshot.SnapshotShardsStatsStage`, this affects: + - `snapshot.SnapshotShardsStatus`'s `stage` field. + +### snapshot.ShardsStatsSummary renamed to snapshot.SnapshotShardsStatsSummary +- The `snapshot.ShardsStatsSummary` class has been renamed to `snapshot.SnapshotShardsStatsSummary`, this affects: + - `snapshot.SnapshotShardsStatus`'s `summary` field. + +### snapshot.ShardsStatsSummaryItem renamed to snapshot.SnapshotShardsStatsSummaryItem +- The `snapshot.ShardsStatsSummaryItem` class has been renamed to `snapshot.SnapshotShardsStatsSummaryItem`, this affects: + - `snapshot.SnapshotShardsStatsSummary`'s (previously `snapshot.ShardsStatsSummary`) `incremental` and `total` fields. \ 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/DeleteSnapshotRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotRequest.java similarity index 63% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotRequest.java index 850ca3458c..d1f539cc4a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotRequest.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.snapshot; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; @@ -42,152 +49,203 @@ import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: snapshot.delete.Request /** * Deletes a snapshot. - * */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class DeleteSnapshotRequest extends RequestBase implements ToCopyableBuilder { -public class DeleteSnapshotRequest extends RequestBase { - @Deprecated @Nullable - private final Time masterTimeout; + private final Time clusterManagerTimeout; + @Deprecated @Nullable - private final Time clusterManagerTimeout; + private final Time masterTimeout; + @Nonnull private final String repository; + @Nonnull private final String snapshot; // --------------------------------------------------------------------------------------------- private DeleteSnapshotRequest(Builder builder) { - - this.masterTimeout = builder.masterTimeout; this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.masterTimeout = builder.masterTimeout; this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository"); this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); - } - public static DeleteSnapshotRequest of(Function> fn) { + public static DeleteSnapshotRequest 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 - A repository name *

* API name: {@code repository} + *

*/ + @Nonnull public final String repository() { return this.repository; } /** - * Required - A snapshot name + * Required - A comma-separated list of snapshot names *

* API name: {@code snapshot} + *

*/ + @Nonnull public final String snapshot() { return this.snapshot; } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link DeleteSnapshotRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Deprecated + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private Time clusterManagerTimeout; @Nullable private Time masterTimeout; + private String repository; + private String snapshot; - @Nullable - private Time clusterManagerTimeout; + public Builder() {} - private String repository; + private Builder(DeleteSnapshotRequest o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.masterTimeout = o.masterTimeout; + this.repository = o.repository; + this.snapshot = o.snapshot; + } - private String snapshot; + private Builder(Builder o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.masterTimeout = o.masterTimeout; + this.repository = o.repository; + this.snapshot = o.snapshot; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } /** - * Explicit operation timeout for connection to master node + * Operation timeout for connection to cluster-manager node. *

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

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

*/ - 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 repository(String value) { this.repository = value; return this; } /** - * Required - A snapshot name + * Required - A comma-separated list of snapshot names *

* API name: {@code snapshot} + *

*/ + @Nonnull public final Builder snapshot(String value) { this.snapshot = value; return this; @@ -196,9 +254,10 @@ public final Builder snapshot(String value) { /** * Builds a {@link DeleteSnapshotRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public DeleteSnapshotRequest build() { _checkSingleUse(); @@ -212,50 +271,51 @@ public DeleteSnapshotRequest build() { * Endpoint "{@code snapshot.delete}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "DELETE"; - - }, - + request -> "DELETE", // Request path request -> { - final int _repository = 1 << 0; - final int _snapshot = 1 << 1; - - int propsSet = 0; - - propsSet |= _repository; - propsSet |= _snapshot; - - if (propsSet == (_repository | _snapshot)) { - StringBuilder buf = new StringBuilder(); - buf.append("/_snapshot"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.repository, buf); - buf.append("/"); - SimpleEndpoint.pathEncode(request.snapshot, buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_snapshot/"); + SimpleEndpoint.pathEncode(request.repository, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.snapshot, buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); - } if (request.clusterManagerTimeout != null) { params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } return params; - }, SimpleEndpoint.emptyMap(), false, DeleteSnapshotResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + this.repository.hashCode(); + result = 31 * result + this.snapshot.hashCode(); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + DeleteSnapshotRequest other = (DeleteSnapshotRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && this.repository.equals(other.repository) + && this.snapshot.equals(other.snapshot); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotResponse.java similarity index 62% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotResponse.java index adb84b2fe2..1b0d535350 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/DeleteSnapshotResponse.java @@ -30,39 +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.Response @JsonpDeserializable -public class DeleteSnapshotResponse extends AcknowledgedResponseBase { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class DeleteSnapshotResponse extends AcknowledgedResponseBase + implements + ToCopyableBuilder { + // --------------------------------------------------------------------------------------------- private DeleteSnapshotResponse(Builder builder) { super(builder); - } - public static DeleteSnapshotResponse of(Function> fn) { + public static DeleteSnapshotResponse 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 DeleteSnapshotResponse}. */ + public static class Builder extends AcknowledgedResponseBase.AbstractBuilder + implements + CopyableBuilder { + + public Builder() {} + + private Builder(DeleteSnapshotResponse o) { + super(o); + } + + private Builder(Builder o) { + super(o); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } - public static class Builder extends AcknowledgedResponseBase.AbstractBuilder implements ObjectBuilder { @Override + @Nonnull protected Builder self() { return this; } @@ -70,9 +111,10 @@ protected Builder self() { /** * Builds a {@link DeleteSnapshotResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public DeleteSnapshotResponse build() { _checkSingleUse(); @@ -91,8 +133,22 @@ public DeleteSnapshotResponse build() { ); protected static void setupDeleteSnapshotResponseDeserializer(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/FileCountSnapshotStats.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/FileCountSnapshotStats.java similarity index 68% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/FileCountSnapshotStats.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/FileCountSnapshotStats.java index 710ad248a8..845a842775 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/FileCountSnapshotStats.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/FileCountSnapshotStats.java @@ -30,10 +30,16 @@ * 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.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.JsonpMapper; @@ -41,13 +47,20 @@ 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.FileCountSnapshotStats +// typedef: snapshot.FileCountSnapshotStats @JsonpDeserializable -public class FileCountSnapshotStats implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class FileCountSnapshotStats + implements + PlainJsonSerializable, + ToCopyableBuilder { + private final int fileCount; private final long sizeInBytes; @@ -55,13 +68,11 @@ public class FileCountSnapshotStats implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private FileCountSnapshotStats(Builder builder) { - this.fileCount = ApiTypeHelper.requireNonNull(builder.fileCount, this, "fileCount"); this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes"); - } - public static FileCountSnapshotStats of(Function> fn) { + public static FileCountSnapshotStats of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -82,6 +93,7 @@ public final long sizeInBytes() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -89,29 +101,55 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("file_count"); generator.write(this.fileCount); generator.writeKey("size_in_bytes"); generator.write(this.sizeInBytes); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link FileCountSnapshotStats}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private Integer fileCount; - private Long sizeInBytes; + public Builder() {} + + private Builder(FileCountSnapshotStats o) { + this.fileCount = o.fileCount; + this.sizeInBytes = o.sizeInBytes; + } + + private Builder(Builder o) { + this.fileCount = o.fileCount; + this.sizeInBytes = o.sizeInBytes; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * Required - API name: {@code file_count} */ + @Nonnull public final Builder fileCount(int value) { this.fileCount = value; return this; @@ -120,6 +158,7 @@ public final Builder fileCount(int value) { /** * Required - API name: {@code size_in_bytes} */ + @Nonnull public final Builder sizeInBytes(long value) { this.sizeInBytes = value; return this; @@ -128,9 +167,10 @@ public final Builder sizeInBytes(long value) { /** * Builds a {@link FileCountSnapshotStats}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public FileCountSnapshotStats build() { _checkSingleUse(); @@ -149,10 +189,23 @@ public FileCountSnapshotStats build() { ); protected static void setupFileCountSnapshotStatsDeserializer(ObjectDeserializer op) { - op.add(Builder::fileCount, JsonpDeserializer.integerDeserializer(), "file_count"); op.add(Builder::sizeInBytes, JsonpDeserializer.longDeserializer(), "size_in_bytes"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Integer.hashCode(this.fileCount); + result = 31 * result + Long.hashCode(this.sizeInBytes); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + FileCountSnapshotStats other = (FileCountSnapshotStats) o; + return this.fileCount == other.fileCount && this.sizeInBytes == other.sizeInBytes; + } } 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/OpenSearchSnapshotAsyncClient.java similarity index 50% rename from java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java index 615f8a5882..cf4f5be9c6 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/OpenSearchSnapshotAsyncClient.java @@ -51,13 +51,20 @@ * Client for the snapshot namespace. */ @Generated("org.opensearch.client.codegen.CodeGenerator") -public abstract class OpenSearchSnapshotAsyncClientBase> extends ApiClient< - OpenSearchTransport, - Self> { - public OpenSearchSnapshotAsyncClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { +public class OpenSearchSnapshotAsyncClient extends ApiClient { + public OpenSearchSnapshotAsyncClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchSnapshotAsyncClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { super(transport, transportOptions); } + @Override + public OpenSearchSnapshotAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchSnapshotAsyncClient(this.transport, transportOptions); + } + // ----- Endpoint: snapshot.cleanup_repository /** @@ -119,6 +126,68 @@ 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 + + /** + * Deletes a snapshot. + */ + public CompletableFuture delete(DeleteSnapshotRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, DeleteSnapshotRequest._ENDPOINT, this.transportOptions); + } + + /** + * Deletes a snapshot. + * + * @param fn a function that initializes a builder to create the {@link DeleteSnapshotRequest} + */ + public final CompletableFuture delete( + Function> fn + ) throws IOException, OpenSearchException { + return delete(fn.apply(new DeleteSnapshotRequest.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 +207,80 @@ 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.restore + + /** + * Restores a snapshot. + */ + public CompletableFuture restore(RestoreSnapshotRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, RestoreSnapshotRequest._ENDPOINT, this.transportOptions); + } + + /** + * Restores a snapshot. + * + * @param fn a function that initializes a builder to create the {@link RestoreSnapshotRequest} + */ + public final CompletableFuture restore( + Function> fn + ) throws IOException, OpenSearchException { + return restore(fn.apply(new RestoreSnapshotRequest.Builder()).build()); + } + + // ----- Endpoint: snapshot.status + + /** + * Returns information about the status of a snapshot. + */ + public CompletableFuture status(SnapshotStatusRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, SnapshotStatusRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about the status of a snapshot. + * + * @param fn a function that initializes a builder to create the {@link SnapshotStatusRequest} + */ + public final CompletableFuture status( + Function> fn + ) throws IOException, OpenSearchException { + return status(fn.apply(new SnapshotStatusRequest.Builder()).build()); + } + + /** + * Returns information about the status of a snapshot. + */ + public final CompletableFuture status() throws IOException, OpenSearchException { + return status(new SnapshotStatusRequest.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/OpenSearchSnapshotClient.java similarity index 50% rename from java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java index 84844ee8cb..31e2215416 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/OpenSearchSnapshotClient.java @@ -50,13 +50,20 @@ * Client for the snapshot namespace. */ @Generated("org.opensearch.client.codegen.CodeGenerator") -public abstract class OpenSearchSnapshotClientBase> extends ApiClient< - OpenSearchTransport, - Self> { - public OpenSearchSnapshotClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { +public class OpenSearchSnapshotClient extends ApiClient { + public OpenSearchSnapshotClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchSnapshotClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { super(transport, transportOptions); } + @Override + public OpenSearchSnapshotClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchSnapshotClient(this.transport, transportOptions); + } + // ----- Endpoint: snapshot.cleanup_repository /** @@ -115,6 +122,65 @@ public final CreateSnapshotResponse create(Function> fn + ) throws IOException, OpenSearchException { + return createRepository(fn.apply(new CreateRepositoryRequest.Builder()).build()); + } + + // ----- Endpoint: snapshot.delete + + /** + * Deletes a snapshot. + */ + public DeleteSnapshotResponse delete(DeleteSnapshotRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, DeleteSnapshotRequest._ENDPOINT, this.transportOptions); + } + + /** + * Deletes a snapshot. + * + * @param fn a function that initializes a builder to create the {@link DeleteSnapshotRequest} + */ + public final DeleteSnapshotResponse delete(Function> fn) + throws IOException, OpenSearchException { + return delete(fn.apply(new DeleteSnapshotRequest.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 +200,77 @@ 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.restore + + /** + * Restores a snapshot. + */ + public RestoreSnapshotResponse restore(RestoreSnapshotRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, RestoreSnapshotRequest._ENDPOINT, this.transportOptions); + } + + /** + * Restores a snapshot. + * + * @param fn a function that initializes a builder to create the {@link RestoreSnapshotRequest} + */ + public final RestoreSnapshotResponse restore(Function> fn) + throws IOException, OpenSearchException { + return restore(fn.apply(new RestoreSnapshotRequest.Builder()).build()); + } + + // ----- Endpoint: snapshot.status + + /** + * Returns information about the status of a snapshot. + */ + public SnapshotStatusResponse status(SnapshotStatusRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, SnapshotStatusRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about the status of a snapshot. + * + * @param fn a function that initializes a builder to create the {@link SnapshotStatusRequest} + */ + public final SnapshotStatusResponse status(Function> fn) + throws IOException, OpenSearchException { + return status(fn.apply(new SnapshotStatusRequest.Builder()).build()); + } + + /** + * Returns information about the status of a snapshot. + */ + public final SnapshotStatusResponse status() throws IOException, OpenSearchException { + return status(new SnapshotStatusRequest.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/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotRequest.java new file mode 100644 index 0000000000..c781559bee --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotRequest.java @@ -0,0 +1,1020 @@ +/* + * 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. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * 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.List; +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; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.RequestBase; +import org.opensearch.client.opensearch._types.Time; +import org.opensearch.client.opensearch.indices.IndexSettings; +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.restore.Request + +/** + * Restores a snapshot. + */ +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class RestoreSnapshotRequest extends RequestBase + implements + PlainJsonSerializable, + ToCopyableBuilder { + + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull + private final List ignoreIndexSettings; + + @Nullable + private final Boolean ignoreUnavailable; + + @Nullable + private final Boolean includeAliases; + + @Nullable + private final Boolean includeGlobalState; + + @Nullable + private final IndexSettings indexSettings; + + @Nonnull + private final List indices; + + @Deprecated + @Nullable + private final Time masterTimeout; + + @Nullable + private final Boolean partial; + + @Nullable + private final String renameAliasPattern; + + @Nullable + private final String renameAliasReplacement; + + @Nullable + private final String renamePattern; + + @Nullable + private final String renameReplacement; + + @Nonnull + private final String repository; + + @Nonnull + private final String snapshot; + + @Nullable + private final String sourceRemoteStoreRepository; + + @Nullable + private final String storageType; + + @Nullable + private final Boolean waitForCompletion; + + // --------------------------------------------------------------------------------------------- + + private RestoreSnapshotRequest(Builder builder) { + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.ignoreIndexSettings = ApiTypeHelper.unmodifiable(builder.ignoreIndexSettings); + this.ignoreUnavailable = builder.ignoreUnavailable; + this.includeAliases = builder.includeAliases; + this.includeGlobalState = builder.includeGlobalState; + this.indexSettings = builder.indexSettings; + this.indices = ApiTypeHelper.unmodifiable(builder.indices); + this.masterTimeout = builder.masterTimeout; + this.partial = builder.partial; + this.renameAliasPattern = builder.renameAliasPattern; + this.renameAliasReplacement = builder.renameAliasReplacement; + this.renamePattern = builder.renamePattern; + this.renameReplacement = builder.renameReplacement; + this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository"); + this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); + this.sourceRemoteStoreRepository = builder.sourceRemoteStoreRepository; + this.storageType = builder.storageType; + this.waitForCompletion = builder.waitForCompletion; + } + + public static RestoreSnapshotRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * A comma-delimited list of index settings that you don't want to restore from a snapshot. + *

+ * API name: {@code ignore_index_settings} + *

+ */ + @Nonnull + public final List ignoreIndexSettings() { + return this.ignoreIndexSettings; + } + + /** + * How to handle data streams or indexes that are missing or closed. If false, the request returns an error for any data + * stream or index that is missing or closed. If true, the request ignores data streams and indexes in indexes that are + * missing or closed. Defaults to false. + *

+ * API name: {@code ignore_unavailable} + *

+ */ + @Nullable + public final Boolean ignoreUnavailable() { + return this.ignoreUnavailable; + } + + /** + * How to handle index aliases from the original snapshot. If true, index aliases from the original snapshot are restored. + * If false, aliases along with associated indexes are not restored. Defaults to true. + *

+ * API name: {@code include_aliases} + *

+ */ + @Nullable + public final Boolean includeAliases() { + return this.includeAliases; + } + + /** + * Whether to restore the current cluster state. If false, the cluster state is not restored. If true, the current cluster + * state is restored. Defaults to false. + *

+ * API name: {@code include_global_state} + *

+ */ + @Nullable + public final Boolean includeGlobalState() { + return this.includeGlobalState; + } + + /** + * A comma-delimited list of settings to add or change in all restored indexes. Use this parameter to override index settings during + * snapshot restoration. For data streams, these index settings are applied to the restored backing indexes. + *

+ * API name: {@code index_settings} + *

+ */ + @Nullable + public final IndexSettings indexSettings() { + return this.indexSettings; + } + + /** + * A comma-delimited list of data streams and indexes to restore from the snapshot. Multi-index syntax is supported. By default, a + * restore operation includes all data streams and indexes in the snapshot. If this argument is provided, the restore operation only + * includes the data streams and indexes that you specify. + *

+ * API name: {@code indices} + *

+ */ + @Nonnull + public final List indices() { + return this.indices; + } + + /** + * Explicit operation timeout for connection to cluster-manager node + *

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

+ */ + @Deprecated + @Nullable + public final Time masterTimeout() { + return this.masterTimeout; + } + + /** + * How the restore operation will behave if indexes in the snapshot do not have all primary shards available. If false, the + * entire restore operation fails if any indexes in the snapshot do not have all primary shards available. If true, allows + * the restoration of a partial snapshot of indexes with unavailable shards. Only shards that were successfully included in the snapshot + * are restored. All missing shards are recreated as empty. By default, the entire restore operation fails if one or more indexes + * included in the snapshot do not have all primary shards available. To change this behavior, set partial to + * true. Defaults to false. + *

+ * API name: {@code partial} + *

+ */ + @Nullable + public final Boolean partial() { + return this.partial; + } + + /** + * The pattern to apply to the restored aliases. Aliases matching the rename pattern will be renamed according to the + * rename_alias_replacement setting. The rename pattern is applied as defined by the regular expression that supports + * referencing the original text. If two or more aliases are renamed into the same name, these aliases will be merged into one. + *

+ * API name: {@code rename_alias_pattern} + *

+ */ + @Nullable + public final String renameAliasPattern() { + return this.renameAliasPattern; + } + + /** + * The rename replacement string for aliases. + *

+ * API name: {@code rename_alias_replacement} + *

+ */ + @Nullable + public final String renameAliasReplacement() { + return this.renameAliasReplacement; + } + + /** + * The pattern to apply to the restored data streams and indexes. Data streams and indexes matching the rename pattern will be renamed + * according to the rename_replacement setting. The rename pattern is applied as defined by the regular expression that + * supports referencing the original text. The request fails if two or more data streams or indexes are renamed into the same name. If + * you rename a restored data stream, its backing indexes are also renamed. For example, if you rename the logs data stream to + * recovered-logs, the backing index .ds-logs-1 is renamed to .ds-recovered-logs-1. If you rename + * a restored stream, ensure an index template matches the new stream name. If there are no matching index template names, the stream + * cannot roll over and new backing indexes are not created. + *

+ * API name: {@code rename_pattern} + *

+ */ + @Nullable + public final String renamePattern() { + return this.renamePattern; + } + + /** + * The rename replacement string. + *

+ * API name: {@code rename_replacement} + *

+ */ + @Nullable + public final String renameReplacement() { + return this.renameReplacement; + } + + /** + * Required - A repository name + *

+ * API name: {@code repository} + *

+ */ + @Nonnull + public final String repository() { + return this.repository; + } + + /** + * Required - A snapshot name + *

+ * API name: {@code snapshot} + *

+ */ + @Nonnull + public final String snapshot() { + return this.snapshot; + } + + /** + * The name of the remote store repository of the source index being restored. If not provided, the Snapshot Restore API will use the + * repository that was registered when the snapshot was created. + *

+ * API name: {@code source_remote_store_repository} + *

+ */ + @Nullable + public final String sourceRemoteStoreRepository() { + return this.sourceRemoteStoreRepository; + } + + /** + * Where will be the authoritative store of the restored indexes' data. A value of local indicates that all snapshot + * metadata and index data will be downloaded to local storage. A value of remote_snapshot indicates that snapshot metadata + * will be downloaded to the cluster, but the remote repository will remain the authoritative store of the index data. Data will be + * downloaded and cached as necessary to service queries. At least one node in the cluster must be configured with the search role in + * order to restore a snapshot using the type remote_snapshot. Defaults to local. + *

+ * API name: {@code storage_type} + *

+ */ + @Nullable + public final String storageType() { + return this.storageType; + } + + /** + * Should this request wait until the operation has completed before returning + *

+ * API name: {@code wait_for_completion} + *

+ */ + @Nullable + public final Boolean waitForCompletion() { + return this.waitForCompletion; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (ApiTypeHelper.isDefined(this.ignoreIndexSettings)) { + generator.writeKey("ignore_index_settings"); + generator.writeStartArray(); + for (String item0 : this.ignoreIndexSettings) { + generator.write(item0); + } + generator.writeEnd(); + } + + if (this.ignoreUnavailable != null) { + generator.writeKey("ignore_unavailable"); + generator.write(this.ignoreUnavailable); + } + + if (this.includeAliases != null) { + generator.writeKey("include_aliases"); + generator.write(this.includeAliases); + } + + if (this.includeGlobalState != null) { + generator.writeKey("include_global_state"); + generator.write(this.includeGlobalState); + } + + if (this.indexSettings != null) { + generator.writeKey("index_settings"); + this.indexSettings.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.indices)) { + generator.writeKey("indices"); + generator.writeStartArray(); + for (String item0 : this.indices) { + generator.write(item0); + } + generator.writeEnd(); + } + + if (this.partial != null) { + generator.writeKey("partial"); + generator.write(this.partial); + } + + if (this.renameAliasPattern != null) { + generator.writeKey("rename_alias_pattern"); + generator.write(this.renameAliasPattern); + } + + if (this.renameAliasReplacement != null) { + generator.writeKey("rename_alias_replacement"); + generator.write(this.renameAliasReplacement); + } + + if (this.renamePattern != null) { + generator.writeKey("rename_pattern"); + generator.write(this.renamePattern); + } + + if (this.renameReplacement != null) { + generator.writeKey("rename_replacement"); + generator.write(this.renameReplacement); + } + + if (this.sourceRemoteStoreRepository != null) { + generator.writeKey("source_remote_store_repository"); + generator.write(this.sourceRemoteStoreRepository); + } + + if (this.storageType != null) { + generator.writeKey("storage_type"); + generator.write(this.storageType); + } + } + // --------------------------------------------------------------------------------------------- + + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + + /** + * Builder for {@link RestoreSnapshotRequest}. + */ + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private Time clusterManagerTimeout; + @Nullable + private List ignoreIndexSettings; + @Nullable + private Boolean ignoreUnavailable; + @Nullable + private Boolean includeAliases; + @Nullable + private Boolean includeGlobalState; + @Nullable + private IndexSettings indexSettings; + @Nullable + private List indices; + @Nullable + private Time masterTimeout; + @Nullable + private Boolean partial; + @Nullable + private String renameAliasPattern; + @Nullable + private String renameAliasReplacement; + @Nullable + private String renamePattern; + @Nullable + private String renameReplacement; + private String repository; + private String snapshot; + @Nullable + private String sourceRemoteStoreRepository; + @Nullable + private String storageType; + @Nullable + private Boolean waitForCompletion; + + public Builder() {} + + private Builder(RestoreSnapshotRequest o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.ignoreIndexSettings = _listCopy(o.ignoreIndexSettings); + this.ignoreUnavailable = o.ignoreUnavailable; + this.includeAliases = o.includeAliases; + this.includeGlobalState = o.includeGlobalState; + this.indexSettings = o.indexSettings; + this.indices = _listCopy(o.indices); + this.masterTimeout = o.masterTimeout; + this.partial = o.partial; + this.renameAliasPattern = o.renameAliasPattern; + this.renameAliasReplacement = o.renameAliasReplacement; + this.renamePattern = o.renamePattern; + this.renameReplacement = o.renameReplacement; + this.repository = o.repository; + this.snapshot = o.snapshot; + this.sourceRemoteStoreRepository = o.sourceRemoteStoreRepository; + this.storageType = o.storageType; + this.waitForCompletion = o.waitForCompletion; + } + + private Builder(Builder o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.ignoreIndexSettings = _listCopy(o.ignoreIndexSettings); + this.ignoreUnavailable = o.ignoreUnavailable; + this.includeAliases = o.includeAliases; + this.includeGlobalState = o.includeGlobalState; + this.indexSettings = o.indexSettings; + this.indices = _listCopy(o.indices); + this.masterTimeout = o.masterTimeout; + this.partial = o.partial; + this.renameAliasPattern = o.renameAliasPattern; + this.renameAliasReplacement = o.renameAliasReplacement; + this.renamePattern = o.renamePattern; + this.renameReplacement = o.renameReplacement; + this.repository = o.repository; + this.snapshot = o.snapshot; + this.sourceRemoteStoreRepository = o.sourceRemoteStoreRepository; + this.storageType = o.storageType; + this.waitForCompletion = o.waitForCompletion; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + + /** + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nonnull + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; + return this; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nonnull + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * A comma-delimited list of index settings that you don't want to restore from a snapshot. + *

+ * API name: {@code ignore_index_settings} + *

+ * + *

+ * Adds all elements of list to ignoreIndexSettings. + *

+ */ + @Nonnull + public final Builder ignoreIndexSettings(List list) { + this.ignoreIndexSettings = _listAddAll(this.ignoreIndexSettings, list); + return this; + } + + /** + * A comma-delimited list of index settings that you don't want to restore from a snapshot. + *

+ * API name: {@code ignore_index_settings} + *

+ * + *

+ * Adds one or more values to ignoreIndexSettings. + *

+ */ + @Nonnull + public final Builder ignoreIndexSettings(String value, String... values) { + this.ignoreIndexSettings = _listAdd(this.ignoreIndexSettings, value, values); + return this; + } + + /** + * How to handle data streams or indexes that are missing or closed. If false, the request returns an error for any + * data stream or index that is missing or closed. If true, the request ignores data streams and indexes in indexes + * that are missing or closed. Defaults to false. + *

+ * API name: {@code ignore_unavailable} + *

+ */ + @Nonnull + public final Builder ignoreUnavailable(@Nullable Boolean value) { + this.ignoreUnavailable = value; + return this; + } + + /** + * How to handle index aliases from the original snapshot. If true, index aliases from the original snapshot are + * restored. If false, aliases along with associated indexes are not restored. Defaults to true. + *

+ * API name: {@code include_aliases} + *

+ */ + @Nonnull + public final Builder includeAliases(@Nullable Boolean value) { + this.includeAliases = value; + return this; + } + + /** + * Whether to restore the current cluster state. If false, the cluster state is not restored. If true, the current + * cluster state is restored. Defaults to false. + *

+ * API name: {@code include_global_state} + *

+ */ + @Nonnull + public final Builder includeGlobalState(@Nullable Boolean value) { + this.includeGlobalState = value; + return this; + } + + /** + * A comma-delimited list of settings to add or change in all restored indexes. Use this parameter to override index settings during + * snapshot restoration. For data streams, these index settings are applied to the restored backing indexes. + *

+ * API name: {@code index_settings} + *

+ */ + @Nonnull + public final Builder indexSettings(@Nullable IndexSettings value) { + this.indexSettings = value; + return this; + } + + /** + * A comma-delimited list of settings to add or change in all restored indexes. Use this parameter to override index settings during + * snapshot restoration. For data streams, these index settings are applied to the restored backing indexes. + *

+ * API name: {@code index_settings} + *

+ */ + @Nonnull + public final Builder indexSettings(Function> fn) { + return indexSettings(fn.apply(new IndexSettings.Builder()).build()); + } + + /** + * A comma-delimited list of data streams and indexes to restore from the snapshot. Multi-index syntax is supported. By default, a + * restore operation includes all data streams and indexes in the snapshot. If this argument is provided, the restore operation only + * includes the data streams and indexes that you specify. + *

+ * API name: {@code indices} + *

+ * + *

+ * Adds all elements of list to indices. + *

+ */ + @Nonnull + public final Builder indices(List list) { + this.indices = _listAddAll(this.indices, list); + return this; + } + + /** + * A comma-delimited list of data streams and indexes to restore from the snapshot. Multi-index syntax is supported. By default, a + * restore operation includes all data streams and indexes in the snapshot. If this argument is provided, the restore operation only + * includes the data streams and indexes that you specify. + *

+ * API name: {@code indices} + *

+ * + *

+ * Adds one or more values to indices. + *

+ */ + @Nonnull + public final Builder indices(String value, String... values) { + this.indices = _listAdd(this.indices, value, values); + return this; + } + + /** + * Explicit operation timeout for connection to cluster-manager node + *

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

+ */ + @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 master_timeout} + *

+ */ + @Deprecated + @Nonnull + public final Builder masterTimeout(Function> fn) { + return masterTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * How the restore operation will behave if indexes in the snapshot do not have all primary shards available. If false, + * the entire restore operation fails if any indexes in the snapshot do not have all primary shards available. If true, + * allows the restoration of a partial snapshot of indexes with unavailable shards. Only shards that were successfully included in + * the snapshot are restored. All missing shards are recreated as empty. By default, the entire restore operation fails if one or + * more indexes included in the snapshot do not have all primary shards available. To change this behavior, set partial + * to true. Defaults to false. + *

+ * API name: {@code partial} + *

+ */ + @Nonnull + public final Builder partial(@Nullable Boolean value) { + this.partial = value; + return this; + } + + /** + * The pattern to apply to the restored aliases. Aliases matching the rename pattern will be renamed according to the + * rename_alias_replacement setting. The rename pattern is applied as defined by the regular expression that supports + * referencing the original text. If two or more aliases are renamed into the same name, these aliases will be merged into one. + *

+ * API name: {@code rename_alias_pattern} + *

+ */ + @Nonnull + public final Builder renameAliasPattern(@Nullable String value) { + this.renameAliasPattern = value; + return this; + } + + /** + * The rename replacement string for aliases. + *

+ * API name: {@code rename_alias_replacement} + *

+ */ + @Nonnull + public final Builder renameAliasReplacement(@Nullable String value) { + this.renameAliasReplacement = value; + return this; + } + + /** + * The pattern to apply to the restored data streams and indexes. Data streams and indexes matching the rename pattern will be + * renamed according to the rename_replacement setting. The rename pattern is applied as defined by the regular + * expression that supports referencing the original text. The request fails if two or more data streams or indexes are renamed into + * the same name. If you rename a restored data stream, its backing indexes are also renamed. For example, if you rename the logs + * data stream to recovered-logs, the backing index .ds-logs-1 is renamed to + * .ds-recovered-logs-1. If you rename a restored stream, ensure an index template matches the new stream name. If + * there are no matching index template names, the stream cannot roll over and new backing indexes are not created. + *

+ * API name: {@code rename_pattern} + *

+ */ + @Nonnull + public final Builder renamePattern(@Nullable String value) { + this.renamePattern = value; + return this; + } + + /** + * The rename replacement string. + *

+ * API name: {@code rename_replacement} + *

+ */ + @Nonnull + public final Builder renameReplacement(@Nullable String value) { + this.renameReplacement = value; + return this; + } + + /** + * Required - A repository name + *

+ * API name: {@code repository} + *

+ */ + @Nonnull + public final Builder repository(String value) { + this.repository = value; + return this; + } + + /** + * Required - A snapshot name + *

+ * API name: {@code snapshot} + *

+ */ + @Nonnull + public final Builder snapshot(String value) { + this.snapshot = value; + return this; + } + + /** + * The name of the remote store repository of the source index being restored. If not provided, the Snapshot Restore API will use + * the repository that was registered when the snapshot was created. + *

+ * API name: {@code source_remote_store_repository} + *

+ */ + @Nonnull + public final Builder sourceRemoteStoreRepository(@Nullable String value) { + this.sourceRemoteStoreRepository = value; + return this; + } + + /** + * Where will be the authoritative store of the restored indexes' data. A value of local indicates that all snapshot + * metadata and index data will be downloaded to local storage. A value of remote_snapshot indicates that snapshot + * metadata will be downloaded to the cluster, but the remote repository will remain the authoritative store of the index data. Data + * will be downloaded and cached as necessary to service queries. At least one node in the cluster must be configured with the + * search role in order to restore a snapshot using the type remote_snapshot. Defaults to local. + *

+ * API name: {@code storage_type} + *

+ */ + @Nonnull + public final Builder storageType(@Nullable String value) { + this.storageType = value; + return this; + } + + /** + * Should this request wait until the operation has completed before returning + *

+ * API name: {@code wait_for_completion} + *

+ */ + @Nonnull + public final Builder waitForCompletion(@Nullable Boolean value) { + this.waitForCompletion = value; + return this; + } + + /** + * Builds a {@link RestoreSnapshotRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + @Override + @Nonnull + public RestoreSnapshotRequest build() { + _checkSingleUse(); + + return new RestoreSnapshotRequest(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RestoreSnapshotRequest} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + RestoreSnapshotRequest::setupRestoreSnapshotRequestDeserializer + ); + + protected static void setupRestoreSnapshotRequestDeserializer(ObjectDeserializer op) { + op.add( + Builder::ignoreIndexSettings, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "ignore_index_settings" + ); + op.add(Builder::ignoreUnavailable, JsonpDeserializer.booleanDeserializer(), "ignore_unavailable"); + op.add(Builder::includeAliases, JsonpDeserializer.booleanDeserializer(), "include_aliases"); + op.add(Builder::includeGlobalState, JsonpDeserializer.booleanDeserializer(), "include_global_state"); + op.add(Builder::indexSettings, IndexSettings._DESERIALIZER, "index_settings"); + op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); + op.add(Builder::partial, JsonpDeserializer.booleanDeserializer(), "partial"); + op.add(Builder::renameAliasPattern, JsonpDeserializer.stringDeserializer(), "rename_alias_pattern"); + op.add(Builder::renameAliasReplacement, JsonpDeserializer.stringDeserializer(), "rename_alias_replacement"); + op.add(Builder::renamePattern, JsonpDeserializer.stringDeserializer(), "rename_pattern"); + op.add(Builder::renameReplacement, JsonpDeserializer.stringDeserializer(), "rename_replacement"); + op.add(Builder::repository, JsonpDeserializer.stringDeserializer(), "repository"); + op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); + op.add(Builder::sourceRemoteStoreRepository, JsonpDeserializer.stringDeserializer(), "source_remote_store_repository"); + op.add(Builder::storageType, JsonpDeserializer.stringDeserializer(), "storage_type"); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code snapshot.restore}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + // Request method + request -> "POST", + // Request path + request -> { + StringBuilder buf = new StringBuilder(); + buf.append("/_snapshot/"); + SimpleEndpoint.pathEncode(request.repository, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.snapshot, buf); + buf.append("/_restore"); + return buf.toString(); + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + 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.waitForCompletion != null) { + params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + RestoreSnapshotResponse._DESERIALIZER + ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.ignoreIndexSettings); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.includeAliases); + result = 31 * result + Objects.hashCode(this.includeGlobalState); + result = 31 * result + Objects.hashCode(this.indexSettings); + result = 31 * result + Objects.hashCode(this.indices); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + Objects.hashCode(this.partial); + result = 31 * result + Objects.hashCode(this.renameAliasPattern); + result = 31 * result + Objects.hashCode(this.renameAliasReplacement); + result = 31 * result + Objects.hashCode(this.renamePattern); + result = 31 * result + Objects.hashCode(this.renameReplacement); + result = 31 * result + this.repository.hashCode(); + result = 31 * result + this.snapshot.hashCode(); + result = 31 * result + Objects.hashCode(this.sourceRemoteStoreRepository); + result = 31 * result + Objects.hashCode(this.storageType); + result = 31 * result + Objects.hashCode(this.waitForCompletion); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + RestoreSnapshotRequest other = (RestoreSnapshotRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.ignoreIndexSettings, other.ignoreIndexSettings) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.includeAliases, other.includeAliases) + && Objects.equals(this.includeGlobalState, other.includeGlobalState) + && Objects.equals(this.indexSettings, other.indexSettings) + && Objects.equals(this.indices, other.indices) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.partial, other.partial) + && Objects.equals(this.renameAliasPattern, other.renameAliasPattern) + && Objects.equals(this.renameAliasReplacement, other.renameAliasReplacement) + && Objects.equals(this.renamePattern, other.renamePattern) + && Objects.equals(this.renameReplacement, other.renameReplacement) + && this.repository.equals(other.repository) + && this.snapshot.equals(other.snapshot) + && Objects.equals(this.sourceRemoteStoreRepository, other.sourceRemoteStoreRepository) + && Objects.equals(this.storageType, other.storageType) + && Objects.equals(this.waitForCompletion, other.waitForCompletion); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotResponse.java new file mode 100644 index 0000000000..7b8ec6bcc7 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotResponse.java @@ -0,0 +1,239 @@ +/* + * 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. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * 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; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch.snapshot.restore.SnapshotRestore; +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.restore.Response + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class RestoreSnapshotResponse + implements + PlainJsonSerializable, + ToCopyableBuilder { + + @Nullable + private final Boolean accepted; + + @Nullable + private final SnapshotRestore snapshot; + + // --------------------------------------------------------------------------------------------- + + private RestoreSnapshotResponse(Builder builder) { + this.accepted = builder.accepted; + this.snapshot = builder.snapshot; + } + + public static RestoreSnapshotResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Returns true if the restore was accepted. Present when the request had wait_for_completion set to + * false. + *

+ * API name: {@code accepted} + *

+ */ + @Nullable + public final Boolean accepted() { + return this.accepted; + } + + /** + * API name: {@code snapshot} + */ + @Nullable + public final SnapshotRestore snapshot() { + return this.snapshot; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.accepted != null) { + generator.writeKey("accepted"); + generator.write(this.accepted); + } + + if (this.snapshot != null) { + generator.writeKey("snapshot"); + this.snapshot.serialize(generator, mapper); + } + } + + // --------------------------------------------------------------------------------------------- + + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + + /** + * Builder for {@link RestoreSnapshotResponse}. + */ + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private Boolean accepted; + @Nullable + private SnapshotRestore snapshot; + + public Builder() {} + + private Builder(RestoreSnapshotResponse o) { + this.accepted = o.accepted; + this.snapshot = o.snapshot; + } + + private Builder(Builder o) { + this.accepted = o.accepted; + this.snapshot = o.snapshot; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + + /** + * Returns true if the restore was accepted. Present when the request had wait_for_completion set to + * false. + *

+ * API name: {@code accepted} + *

+ */ + @Nonnull + public final Builder accepted(@Nullable Boolean value) { + this.accepted = value; + return this; + } + + /** + * API name: {@code snapshot} + */ + @Nonnull + public final Builder snapshot(@Nullable SnapshotRestore value) { + this.snapshot = value; + return this; + } + + /** + * API name: {@code snapshot} + */ + @Nonnull + public final Builder snapshot(Function> fn) { + return snapshot(fn.apply(new SnapshotRestore.Builder()).build()); + } + + /** + * Builds a {@link RestoreSnapshotResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + @Override + @Nonnull + public RestoreSnapshotResponse build() { + _checkSingleUse(); + + return new RestoreSnapshotResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RestoreSnapshotResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + RestoreSnapshotResponse::setupRestoreSnapshotResponseDeserializer + ); + + protected static void setupRestoreSnapshotResponseDeserializer(ObjectDeserializer op) { + op.add(Builder::accepted, JsonpDeserializer.booleanDeserializer(), "accepted"); + op.add(Builder::snapshot, SnapshotRestore._DESERIALIZER, "snapshot"); + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.accepted); + result = 31 * result + Objects.hashCode(this.snapshot); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + RestoreSnapshotResponse other = (RestoreSnapshotResponse) o; + return Objects.equals(this.accepted, other.accepted) && Objects.equals(this.snapshot, other.snapshot); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotIndexStats.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotIndexStats.java similarity index 63% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotIndexStats.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotIndexStats.java index 52ca17a410..8baa468509 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotIndexStats.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotIndexStats.java @@ -30,11 +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.Map; 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.JsonpMapper; @@ -42,36 +48,42 @@ 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.SnapshotIndexStats +// typedef: snapshot.SnapshotIndexStats @JsonpDeserializable -public class SnapshotIndexStats implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotIndexStats implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull private final Map shards; - private final ShardsStats shardsStats; + @Nonnull + private final SnapshotShardsStats shardsStats; + @Nonnull private final SnapshotStats stats; // --------------------------------------------------------------------------------------------- private SnapshotIndexStats(Builder builder) { - this.shards = ApiTypeHelper.unmodifiableRequired(builder.shards, this, "shards"); this.shardsStats = ApiTypeHelper.requireNonNull(builder.shardsStats, this, "shardsStats"); this.stats = ApiTypeHelper.requireNonNull(builder.stats, this, "stats"); - } - public static SnapshotIndexStats of(Function> fn) { + public static SnapshotIndexStats of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code shards} */ + @Nonnull public final Map shards() { return this.shards; } @@ -79,13 +91,15 @@ public final Map shards() { /** * Required - API name: {@code shards_stats} */ - public final ShardsStats shardsStats() { + @Nonnull + public final SnapshotShardsStats shardsStats() { return this.shardsStats; } /** * Required - API name: {@code stats} */ + @Nonnull public final SnapshotStats stats() { return this.stats; } @@ -93,6 +107,7 @@ public final SnapshotStats stats() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -100,44 +115,70 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.shards)) { - generator.writeKey("shards"); - generator.writeStartObject(); - for (Map.Entry item0 : this.shards.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - + generator.writeKey("shards"); + generator.writeStartObject(); + for (Map.Entry item0 : this.shards.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); } + generator.writeEnd(); + generator.writeKey("shards_stats"); this.shardsStats.serialize(generator, mapper); generator.writeKey("stats"); this.stats.serialize(generator, mapper); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link SnapshotIndexStats}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private Map shards; + private SnapshotShardsStats shardsStats; + private SnapshotStats stats; - private ShardsStats shardsStats; + public Builder() {} - private SnapshotStats stats; + private Builder(SnapshotIndexStats o) { + this.shards = _mapCopy(o.shards); + this.shardsStats = o.shardsStats; + this.stats = o.stats; + } + + private Builder(Builder o) { + this.shards = _mapCopy(o.shards); + this.shardsStats = o.shardsStats; + this.stats = o.stats; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } /** * Required - API name: {@code shards} + * *

- * Adds all entries of map to shards. + * Adds all elements of map to shards. + *

*/ + @Nonnull public final Builder shards(Map map) { this.shards = _mapPutAll(this.shards, map); return this; @@ -145,9 +186,12 @@ public final Builder shards(Map map) { /** * Required - API name: {@code shards} + * *

* Adds an entry to shards. + *

*/ + @Nonnull public final Builder shards(String key, SnapshotShardsStatus value) { this.shards = _mapPut(this.shards, key, value); return this; @@ -155,9 +199,12 @@ public final Builder shards(String key, SnapshotShardsStatus value) { /** * Required - API name: {@code shards} + * *

- * Adds an entry to shards using a builder lambda. + * Adds a value to shards using a builder lambda. + *

*/ + @Nonnull public final Builder shards(String key, Function> fn) { return shards(key, fn.apply(new SnapshotShardsStatus.Builder()).build()); } @@ -165,7 +212,8 @@ public final Builder shards(String key, Function> fn) { - return this.shardsStats(fn.apply(new ShardsStats.Builder()).build()); + @Nonnull + public final Builder shardsStats(Function> fn) { + return shardsStats(fn.apply(new SnapshotShardsStats.Builder()).build()); } /** * Required - API name: {@code stats} */ + @Nonnull public final Builder stats(SnapshotStats value) { this.stats = value; return this; @@ -188,16 +238,18 @@ public final Builder stats(SnapshotStats value) { /** * Required - API name: {@code stats} */ + @Nonnull public final Builder stats(Function> fn) { - return this.stats(fn.apply(new SnapshotStats.Builder()).build()); + return stats(fn.apply(new SnapshotStats.Builder()).build()); } /** * Builds a {@link SnapshotIndexStats}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public SnapshotIndexStats build() { _checkSingleUse(); @@ -216,11 +268,25 @@ public SnapshotIndexStats build() { ); protected static void setupSnapshotIndexStatsDeserializer(ObjectDeserializer op) { - op.add(Builder::shards, JsonpDeserializer.stringMapDeserializer(SnapshotShardsStatus._DESERIALIZER), "shards"); - op.add(Builder::shardsStats, ShardsStats._DESERIALIZER, "shards_stats"); + op.add(Builder::shardsStats, SnapshotShardsStats._DESERIALIZER, "shards_stats"); op.add(Builder::stats, SnapshotStats._DESERIALIZER, "stats"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.shards.hashCode(); + result = 31 * result + this.shardsStats.hashCode(); + result = 31 * result + this.stats.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotIndexStats other = (SnapshotIndexStats) o; + return this.shards.equals(other.shards) && this.shardsStats.equals(other.shardsStats) && this.stats.equals(other.stats); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStats.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStats.java similarity index 65% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStats.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStats.java index 1082b64f68..baa3b74d8d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStats.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStats.java @@ -30,10 +30,16 @@ * 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.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.JsonpMapper; @@ -41,13 +47,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.ShardsStats +// typedef: snapshot.SnapshotShardsStats @JsonpDeserializable -public class ShardsStats implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotShardsStats implements PlainJsonSerializable, ToCopyableBuilder { + private final long done; private final long failed; @@ -62,18 +72,16 @@ public class ShardsStats implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- - private ShardsStats(Builder builder) { - + private SnapshotShardsStats(Builder builder) { this.done = ApiTypeHelper.requireNonNull(builder.done, this, "done"); this.failed = ApiTypeHelper.requireNonNull(builder.failed, this, "failed"); this.finalizing = ApiTypeHelper.requireNonNull(builder.finalizing, this, "finalizing"); this.initializing = ApiTypeHelper.requireNonNull(builder.initializing, this, "initializing"); this.started = ApiTypeHelper.requireNonNull(builder.started, this, "started"); this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - } - public static ShardsStats of(Function> fn) { + public static SnapshotShardsStats of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -122,6 +130,7 @@ public final long total() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -129,7 +138,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("done"); generator.write(this.done); @@ -147,31 +155,62 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("total"); generator.write(this.total); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** - * Builder for {@link ShardsStats}. + * Builder for {@link SnapshotShardsStats}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private Long done; - private Long failed; - private Long finalizing; - private Long initializing; - private Long started; - private Long total; + public Builder() {} + + private Builder(SnapshotShardsStats o) { + this.done = o.done; + this.failed = o.failed; + this.finalizing = o.finalizing; + this.initializing = o.initializing; + this.started = o.started; + this.total = o.total; + } + + private Builder(Builder o) { + this.done = o.done; + this.failed = o.failed; + this.finalizing = o.finalizing; + this.initializing = o.initializing; + this.started = o.started; + this.total = o.total; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * Required - API name: {@code done} */ + @Nonnull public final Builder done(long value) { this.done = value; return this; @@ -180,6 +219,7 @@ public final Builder done(long value) { /** * Required - API name: {@code failed} */ + @Nonnull public final Builder failed(long value) { this.failed = value; return this; @@ -188,6 +228,7 @@ public final Builder failed(long value) { /** * Required - API name: {@code finalizing} */ + @Nonnull public final Builder finalizing(long value) { this.finalizing = value; return this; @@ -196,6 +237,7 @@ public final Builder finalizing(long value) { /** * Required - API name: {@code initializing} */ + @Nonnull public final Builder initializing(long value) { this.initializing = value; return this; @@ -204,6 +246,7 @@ public final Builder initializing(long value) { /** * Required - API name: {@code started} */ + @Nonnull public final Builder started(long value) { this.started = value; return this; @@ -212,43 +255,67 @@ public final Builder started(long value) { /** * Required - API name: {@code total} */ + @Nonnull public final Builder total(long value) { this.total = value; return this; } /** - * Builds a {@link ShardsStats}. + * Builds a {@link SnapshotShardsStats}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ - public ShardsStats build() { + @Override + @Nonnull + public SnapshotShardsStats build() { _checkSingleUse(); - return new ShardsStats(this); + return new SnapshotShardsStats(this); } } // --------------------------------------------------------------------------------------------- /** - * Json deserializer for {@link ShardsStats} + * Json deserializer for {@link SnapshotShardsStats} */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( Builder::new, - ShardsStats::setupShardsStatsDeserializer + SnapshotShardsStats::setupSnapshotShardsStatsDeserializer ); - protected static void setupShardsStatsDeserializer(ObjectDeserializer op) { - + protected static void setupSnapshotShardsStatsDeserializer(ObjectDeserializer op) { op.add(Builder::done, JsonpDeserializer.longDeserializer(), "done"); op.add(Builder::failed, JsonpDeserializer.longDeserializer(), "failed"); op.add(Builder::finalizing, JsonpDeserializer.longDeserializer(), "finalizing"); op.add(Builder::initializing, JsonpDeserializer.longDeserializer(), "initializing"); op.add(Builder::started, JsonpDeserializer.longDeserializer(), "started"); op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Long.hashCode(this.done); + result = 31 * result + Long.hashCode(this.failed); + result = 31 * result + Long.hashCode(this.finalizing); + result = 31 * result + Long.hashCode(this.initializing); + result = 31 * result + Long.hashCode(this.started); + result = 31 * result + Long.hashCode(this.total); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotShardsStats other = (SnapshotShardsStats) o; + return this.done == other.done + && this.failed == other.failed + && this.finalizing == other.finalizing + && this.initializing == other.initializing + && this.started == other.started + && this.total == other.total; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStatsStage.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatsStage.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStatsStage.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatsStage.java index 22033a7ddf..78cee56d66 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStatsStage.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatsStage.java @@ -30,48 +30,49 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.snapshot; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: snapshot.SnapshotShardsStatsStage + @JsonpDeserializable -public enum ShardsStatsStage implements JsonEnum { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public enum SnapshotShardsStatsStage implements JsonEnum { /** - * Number of shards in the snapshot that were successfully stored in the - * repository. + * Number of shards in the snapshot that were successfully stored in the repository. */ Done("DONE"), /** - * Number of shards in the snapshot that were not successfully stored in the - * repository. + * Number of shards in the snapshot that were not successfully stored in the repository. */ Failure("FAILURE"), /** - * Number of shards in the snapshot that are in the finalizing stage of being - * stored in the repository. + * Number of shards in the snapshot that are in the finalizing stage of being stored in the repository. */ Finalize("FINALIZE"), /** - * Number of shards in the snapshot that are in the initializing stage of being - * stored in the repository. + * Number of shards in the snapshot that are in the initializing stage of being stored in the repository. */ Init("INIT"), /** - * Number of shards in the snapshot that are in the started stage of being - * stored in the repository. + * Number of shards in the snapshot that are in the started stage of being stored in the repository. */ - Started("STARTED"), - - ; + Started("STARTED"); private final String jsonValue; - ShardsStatsStage(String jsonValue) { + SnapshotShardsStatsStage(String jsonValue) { this.jsonValue = jsonValue; } @@ -79,5 +80,7 @@ public String jsonValue() { return this.jsonValue; } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(ShardsStatsStage.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + SnapshotShardsStatsStage.values() + ); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatsSummary.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatsSummary.java new file mode 100644 index 0000000000..5ba14a343a --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatsSummary.java @@ -0,0 +1,377 @@ +/* + * 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. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * 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; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.Time; +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.SnapshotShardsStatsSummary + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotShardsStatsSummary + implements + PlainJsonSerializable, + ToCopyableBuilder { + + @Nonnull + private final SnapshotShardsStatsSummaryItem incremental; + + @Nullable + private final SnapshotShardsStatsSummaryItem processed; + + private final long startTimeInMillis; + + @Nullable + private final Time time; + + private final long timeInMillis; + + @Nonnull + private final SnapshotShardsStatsSummaryItem total; + + // --------------------------------------------------------------------------------------------- + + private SnapshotShardsStatsSummary(Builder builder) { + this.incremental = ApiTypeHelper.requireNonNull(builder.incremental, this, "incremental"); + this.processed = builder.processed; + this.startTimeInMillis = ApiTypeHelper.requireNonNull(builder.startTimeInMillis, this, "startTimeInMillis"); + this.time = builder.time; + this.timeInMillis = ApiTypeHelper.requireNonNull(builder.timeInMillis, this, "timeInMillis"); + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); + } + + public static SnapshotShardsStatsSummary of( + Function> fn + ) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code incremental} + */ + @Nonnull + public final SnapshotShardsStatsSummaryItem incremental() { + return this.incremental; + } + + /** + * API name: {@code processed} + */ + @Nullable + public final SnapshotShardsStatsSummaryItem processed() { + return this.processed; + } + + /** + * Required - API name: {@code start_time_in_millis} + */ + public final long startTimeInMillis() { + return this.startTimeInMillis; + } + + /** + * API name: {@code time} + */ + @Nullable + public final Time time() { + return this.time; + } + + /** + * Required - API name: {@code time_in_millis} + */ + public final long timeInMillis() { + return this.timeInMillis; + } + + /** + * Required - API name: {@code total} + */ + @Nonnull + public final SnapshotShardsStatsSummaryItem total() { + return this.total; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("incremental"); + this.incremental.serialize(generator, mapper); + + if (this.processed != null) { + generator.writeKey("processed"); + this.processed.serialize(generator, mapper); + } + + generator.writeKey("start_time_in_millis"); + generator.write(this.startTimeInMillis); + + if (this.time != null) { + generator.writeKey("time"); + this.time.serialize(generator, mapper); + } + + generator.writeKey("time_in_millis"); + generator.write(this.timeInMillis); + + generator.writeKey("total"); + this.total.serialize(generator, mapper); + } + + // --------------------------------------------------------------------------------------------- + + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + + /** + * Builder for {@link SnapshotShardsStatsSummary}. + */ + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + private SnapshotShardsStatsSummaryItem incremental; + @Nullable + private SnapshotShardsStatsSummaryItem processed; + private Long startTimeInMillis; + @Nullable + private Time time; + private Long timeInMillis; + private SnapshotShardsStatsSummaryItem total; + + public Builder() {} + + private Builder(SnapshotShardsStatsSummary o) { + this.incremental = o.incremental; + this.processed = o.processed; + this.startTimeInMillis = o.startTimeInMillis; + this.time = o.time; + this.timeInMillis = o.timeInMillis; + this.total = o.total; + } + + private Builder(Builder o) { + this.incremental = o.incremental; + this.processed = o.processed; + this.startTimeInMillis = o.startTimeInMillis; + this.time = o.time; + this.timeInMillis = o.timeInMillis; + this.total = o.total; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + + /** + * Required - API name: {@code incremental} + */ + @Nonnull + public final Builder incremental(SnapshotShardsStatsSummaryItem value) { + this.incremental = value; + return this; + } + + /** + * Required - API name: {@code incremental} + */ + @Nonnull + public final Builder incremental( + Function> fn + ) { + return incremental(fn.apply(new SnapshotShardsStatsSummaryItem.Builder()).build()); + } + + /** + * API name: {@code processed} + */ + @Nonnull + public final Builder processed(@Nullable SnapshotShardsStatsSummaryItem value) { + this.processed = value; + return this; + } + + /** + * API name: {@code processed} + */ + @Nonnull + public final Builder processed(Function> fn) { + return processed(fn.apply(new SnapshotShardsStatsSummaryItem.Builder()).build()); + } + + /** + * Required - API name: {@code start_time_in_millis} + */ + @Nonnull + public final Builder startTimeInMillis(long value) { + this.startTimeInMillis = value; + return this; + } + + /** + * API name: {@code time} + */ + @Nonnull + public final Builder time(@Nullable Time value) { + this.time = value; + return this; + } + + /** + * API name: {@code time} + */ + @Nonnull + public final Builder time(Function> fn) { + return time(fn.apply(new Time.Builder()).build()); + } + + /** + * Required - API name: {@code time_in_millis} + */ + @Nonnull + public final Builder timeInMillis(long value) { + this.timeInMillis = value; + return this; + } + + /** + * Required - API name: {@code total} + */ + @Nonnull + public final Builder total(SnapshotShardsStatsSummaryItem value) { + this.total = value; + return this; + } + + /** + * Required - API name: {@code total} + */ + @Nonnull + public final Builder total(Function> fn) { + return total(fn.apply(new SnapshotShardsStatsSummaryItem.Builder()).build()); + } + + /** + * Builds a {@link SnapshotShardsStatsSummary}. + * + * @throws NullPointerException if some of the required fields are null. + */ + @Override + @Nonnull + public SnapshotShardsStatsSummary build() { + _checkSingleUse(); + + return new SnapshotShardsStatsSummary(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SnapshotShardsStatsSummary} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + SnapshotShardsStatsSummary::setupSnapshotShardsStatsSummaryDeserializer + ); + + protected static void setupSnapshotShardsStatsSummaryDeserializer(ObjectDeserializer op) { + op.add(Builder::incremental, SnapshotShardsStatsSummaryItem._DESERIALIZER, "incremental"); + op.add(Builder::processed, SnapshotShardsStatsSummaryItem._DESERIALIZER, "processed"); + op.add(Builder::startTimeInMillis, JsonpDeserializer.longDeserializer(), "start_time_in_millis"); + op.add(Builder::time, Time._DESERIALIZER, "time"); + op.add(Builder::timeInMillis, JsonpDeserializer.longDeserializer(), "time_in_millis"); + op.add(Builder::total, SnapshotShardsStatsSummaryItem._DESERIALIZER, "total"); + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.incremental.hashCode(); + result = 31 * result + Objects.hashCode(this.processed); + result = 31 * result + Long.hashCode(this.startTimeInMillis); + result = 31 * result + Objects.hashCode(this.time); + result = 31 * result + Long.hashCode(this.timeInMillis); + result = 31 * result + this.total.hashCode(); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotShardsStatsSummary other = (SnapshotShardsStatsSummary) o; + return this.incremental.equals(other.incremental) + && Objects.equals(this.processed, other.processed) + && this.startTimeInMillis == other.startTimeInMillis + && Objects.equals(this.time, other.time) + && this.timeInMillis == other.timeInMillis + && this.total.equals(other.total); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStatsSummaryItem.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatsSummaryItem.java similarity index 57% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStatsSummaryItem.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatsSummaryItem.java index 6c4ef63a6e..a8db86f255 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStatsSummaryItem.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatsSummaryItem.java @@ -30,10 +30,16 @@ * 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.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.JsonpMapper; @@ -41,27 +47,34 @@ 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.ShardsStatsSummaryItem +// typedef: snapshot.SnapshotShardsStatsSummaryItem @JsonpDeserializable -public class ShardsStatsSummaryItem implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotShardsStatsSummaryItem + implements + PlainJsonSerializable, + ToCopyableBuilder { + private final long fileCount; private final long sizeInBytes; // --------------------------------------------------------------------------------------------- - private ShardsStatsSummaryItem(Builder builder) { - + private SnapshotShardsStatsSummaryItem(Builder builder) { this.fileCount = ApiTypeHelper.requireNonNull(builder.fileCount, this, "fileCount"); this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes"); - } - public static ShardsStatsSummaryItem of(Function> fn) { + public static SnapshotShardsStatsSummaryItem of( + Function> fn + ) { return fn.apply(new Builder()).build(); } @@ -82,6 +95,7 @@ public final long sizeInBytes() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -89,29 +103,55 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("file_count"); generator.write(this.fileCount); generator.writeKey("size_in_bytes"); generator.write(this.sizeInBytes); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** - * Builder for {@link ShardsStatsSummaryItem}. + * Builder for {@link SnapshotShardsStatsSummaryItem}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private Long fileCount; - private Long sizeInBytes; + public Builder() {} + + private Builder(SnapshotShardsStatsSummaryItem o) { + this.fileCount = o.fileCount; + this.sizeInBytes = o.sizeInBytes; + } + + private Builder(Builder o) { + this.fileCount = o.fileCount; + this.sizeInBytes = o.sizeInBytes; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * Required - API name: {@code file_count} */ + @Nonnull public final Builder fileCount(long value) { this.fileCount = value; return this; @@ -120,39 +160,54 @@ public final Builder fileCount(long value) { /** * Required - API name: {@code size_in_bytes} */ + @Nonnull public final Builder sizeInBytes(long value) { this.sizeInBytes = value; return this; } /** - * Builds a {@link ShardsStatsSummaryItem}. + * Builds a {@link SnapshotShardsStatsSummaryItem}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ - public ShardsStatsSummaryItem build() { + @Override + @Nonnull + public SnapshotShardsStatsSummaryItem build() { _checkSingleUse(); - return new ShardsStatsSummaryItem(this); + return new SnapshotShardsStatsSummaryItem(this); } } // --------------------------------------------------------------------------------------------- /** - * Json deserializer for {@link ShardsStatsSummaryItem} + * Json deserializer for {@link SnapshotShardsStatsSummaryItem} */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( Builder::new, - ShardsStatsSummaryItem::setupShardsStatsSummaryItemDeserializer + SnapshotShardsStatsSummaryItem::setupSnapshotShardsStatsSummaryItemDeserializer ); - protected static void setupShardsStatsSummaryItemDeserializer(ObjectDeserializer op) { - + protected static void setupSnapshotShardsStatsSummaryItemDeserializer(ObjectDeserializer op) { op.add(Builder::fileCount, JsonpDeserializer.longDeserializer(), "file_count"); op.add(Builder::sizeInBytes, JsonpDeserializer.longDeserializer(), "size_in_bytes"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Long.hashCode(this.fileCount); + result = 31 * result + Long.hashCode(this.sizeInBytes); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotShardsStatsSummaryItem other = (SnapshotShardsStatsSummaryItem) o; + return this.fileCount == other.fileCount && this.sizeInBytes == other.sizeInBytes; + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatus.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatus.java new file mode 100644 index 0000000000..0bdf890f1a --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatus.java @@ -0,0 +1,289 @@ +/* + * 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. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * 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; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +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.SnapshotShardsStatus + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotShardsStatus implements PlainJsonSerializable, ToCopyableBuilder { + + @Nullable + private final String node; + + @Nullable + private final String reason; + + @Nonnull + private final SnapshotShardsStatsStage stage; + + @Nonnull + private final SnapshotShardsStatsSummary stats; + + // --------------------------------------------------------------------------------------------- + + private SnapshotShardsStatus(Builder builder) { + this.node = builder.node; + this.reason = builder.reason; + this.stage = ApiTypeHelper.requireNonNull(builder.stage, this, "stage"); + this.stats = ApiTypeHelper.requireNonNull(builder.stats, this, "stats"); + } + + public static SnapshotShardsStatus of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code node} + */ + @Nullable + public final String node() { + return this.node; + } + + /** + * API name: {@code reason} + */ + @Nullable + public final String reason() { + return this.reason; + } + + /** + * Required - API name: {@code stage} + */ + @Nonnull + public final SnapshotShardsStatsStage stage() { + return this.stage; + } + + /** + * Required - API name: {@code stats} + */ + @Nonnull + public final SnapshotShardsStatsSummary stats() { + return this.stats; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.node != null) { + generator.writeKey("node"); + generator.write(this.node); + } + + if (this.reason != null) { + generator.writeKey("reason"); + generator.write(this.reason); + } + + generator.writeKey("stage"); + this.stage.serialize(generator, mapper); + + generator.writeKey("stats"); + this.stats.serialize(generator, mapper); + } + + // --------------------------------------------------------------------------------------------- + + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + + /** + * Builder for {@link SnapshotShardsStatus}. + */ + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private String node; + @Nullable + private String reason; + private SnapshotShardsStatsStage stage; + private SnapshotShardsStatsSummary stats; + + public Builder() {} + + private Builder(SnapshotShardsStatus o) { + this.node = o.node; + this.reason = o.reason; + this.stage = o.stage; + this.stats = o.stats; + } + + private Builder(Builder o) { + this.node = o.node; + this.reason = o.reason; + this.stage = o.stage; + this.stats = o.stats; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + + /** + * API name: {@code node} + */ + @Nonnull + public final Builder node(@Nullable String value) { + this.node = value; + return this; + } + + /** + * API name: {@code reason} + */ + @Nonnull + public final Builder reason(@Nullable String value) { + this.reason = value; + return this; + } + + /** + * Required - API name: {@code stage} + */ + @Nonnull + public final Builder stage(SnapshotShardsStatsStage value) { + this.stage = value; + return this; + } + + /** + * Required - API name: {@code stats} + */ + @Nonnull + public final Builder stats(SnapshotShardsStatsSummary value) { + this.stats = value; + return this; + } + + /** + * Required - API name: {@code stats} + */ + @Nonnull + public final Builder stats(Function> fn) { + return stats(fn.apply(new SnapshotShardsStatsSummary.Builder()).build()); + } + + /** + * Builds a {@link SnapshotShardsStatus}. + * + * @throws NullPointerException if some of the required fields are null. + */ + @Override + @Nonnull + public SnapshotShardsStatus build() { + _checkSingleUse(); + + return new SnapshotShardsStatus(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SnapshotShardsStatus} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + SnapshotShardsStatus::setupSnapshotShardsStatusDeserializer + ); + + protected static void setupSnapshotShardsStatusDeserializer(ObjectDeserializer op) { + op.add(Builder::node, JsonpDeserializer.stringDeserializer(), "node"); + op.add(Builder::reason, JsonpDeserializer.stringDeserializer(), "reason"); + op.add(Builder::stage, SnapshotShardsStatsStage._DESERIALIZER, "stage"); + op.add(Builder::stats, SnapshotShardsStatsSummary._DESERIALIZER, "stats"); + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.node); + result = 31 * result + Objects.hashCode(this.reason); + result = 31 * result + this.stage.hashCode(); + result = 31 * result + this.stats.hashCode(); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotShardsStatus other = (SnapshotShardsStatus) o; + return Objects.equals(this.node, other.node) + && Objects.equals(this.reason, other.reason) + && this.stage.equals(other.stage) + && this.stats.equals(other.stats); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotStats.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStats.java similarity index 55% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotStats.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStats.java index bb2b44eb3f..a3b0f92572 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotStats.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStats.java @@ -30,54 +30,84 @@ * 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; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.Time; 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.SnapshotStats +// typedef: snapshot.SnapshotStats @JsonpDeserializable -public class SnapshotStats implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotStats implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull private final FileCountSnapshotStats incremental; + @Nullable + private final FileCountSnapshotStats processed; + private final long startTimeInMillis; + @Nullable + private final Time time; + private final long timeInMillis; + @Nonnull private final FileCountSnapshotStats total; // --------------------------------------------------------------------------------------------- private SnapshotStats(Builder builder) { - this.incremental = ApiTypeHelper.requireNonNull(builder.incremental, this, "incremental"); + this.processed = builder.processed; this.startTimeInMillis = ApiTypeHelper.requireNonNull(builder.startTimeInMillis, this, "startTimeInMillis"); + this.time = builder.time; this.timeInMillis = ApiTypeHelper.requireNonNull(builder.timeInMillis, this, "timeInMillis"); this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - } - public static SnapshotStats of(Function> fn) { + public static SnapshotStats of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code incremental} */ + @Nonnull public final FileCountSnapshotStats incremental() { return this.incremental; } + /** + * API name: {@code processed} + */ + @Nullable + public final FileCountSnapshotStats processed() { + return this.processed; + } + /** * Required - API name: {@code start_time_in_millis} */ @@ -85,6 +115,14 @@ public final long startTimeInMillis() { return this.startTimeInMillis; } + /** + * API name: {@code time} + */ + @Nullable + public final Time time() { + return this.time; + } + /** * Required - API name: {@code time_in_millis} */ @@ -95,6 +133,7 @@ public final long timeInMillis() { /** * Required - API name: {@code total} */ + @Nonnull public final FileCountSnapshotStats total() { return this.total; } @@ -102,6 +141,7 @@ public final FileCountSnapshotStats total() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -109,39 +149,85 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("incremental"); this.incremental.serialize(generator, mapper); + if (this.processed != null) { + generator.writeKey("processed"); + this.processed.serialize(generator, mapper); + } + generator.writeKey("start_time_in_millis"); generator.write(this.startTimeInMillis); + if (this.time != null) { + generator.writeKey("time"); + this.time.serialize(generator, mapper); + } + generator.writeKey("time_in_millis"); generator.write(this.timeInMillis); generator.writeKey("total"); this.total.serialize(generator, mapper); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link SnapshotStats}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private FileCountSnapshotStats incremental; - + @Nullable + private FileCountSnapshotStats processed; private Long startTimeInMillis; - + @Nullable + private Time time; private Long timeInMillis; - private FileCountSnapshotStats total; + public Builder() {} + + private Builder(SnapshotStats o) { + this.incremental = o.incremental; + this.processed = o.processed; + this.startTimeInMillis = o.startTimeInMillis; + this.time = o.time; + this.timeInMillis = o.timeInMillis; + this.total = o.total; + } + + private Builder(Builder o) { + this.incremental = o.incremental; + this.processed = o.processed; + this.startTimeInMillis = o.startTimeInMillis; + this.time = o.time; + this.timeInMillis = o.timeInMillis; + this.total = o.total; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * Required - API name: {@code incremental} */ + @Nonnull public final Builder incremental(FileCountSnapshotStats value) { this.incremental = value; return this; @@ -150,21 +236,58 @@ public final Builder incremental(FileCountSnapshotStats value) { /** * Required - API name: {@code incremental} */ + @Nonnull public final Builder incremental(Function> fn) { - return this.incremental(fn.apply(new FileCountSnapshotStats.Builder()).build()); + return incremental(fn.apply(new FileCountSnapshotStats.Builder()).build()); + } + + /** + * API name: {@code processed} + */ + @Nonnull + public final Builder processed(@Nullable FileCountSnapshotStats value) { + this.processed = value; + return this; + } + + /** + * API name: {@code processed} + */ + @Nonnull + public final Builder processed(Function> fn) { + return processed(fn.apply(new FileCountSnapshotStats.Builder()).build()); } /** * Required - API name: {@code start_time_in_millis} */ + @Nonnull public final Builder startTimeInMillis(long value) { this.startTimeInMillis = value; return this; } + /** + * API name: {@code time} + */ + @Nonnull + public final Builder time(@Nullable Time value) { + this.time = value; + return this; + } + + /** + * API name: {@code time} + */ + @Nonnull + public final Builder time(Function> fn) { + return time(fn.apply(new Time.Builder()).build()); + } + /** * Required - API name: {@code time_in_millis} */ + @Nonnull public final Builder timeInMillis(long value) { this.timeInMillis = value; return this; @@ -173,6 +296,7 @@ public final Builder timeInMillis(long value) { /** * Required - API name: {@code total} */ + @Nonnull public final Builder total(FileCountSnapshotStats value) { this.total = value; return this; @@ -181,16 +305,18 @@ public final Builder total(FileCountSnapshotStats value) { /** * Required - API name: {@code total} */ + @Nonnull public final Builder total(Function> fn) { - return this.total(fn.apply(new FileCountSnapshotStats.Builder()).build()); + return total(fn.apply(new FileCountSnapshotStats.Builder()).build()); } /** * Builds a {@link SnapshotStats}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public SnapshotStats build() { _checkSingleUse(); @@ -209,12 +335,36 @@ public SnapshotStats build() { ); protected static void setupSnapshotStatsDeserializer(ObjectDeserializer op) { - op.add(Builder::incremental, FileCountSnapshotStats._DESERIALIZER, "incremental"); + op.add(Builder::processed, FileCountSnapshotStats._DESERIALIZER, "processed"); op.add(Builder::startTimeInMillis, JsonpDeserializer.longDeserializer(), "start_time_in_millis"); + op.add(Builder::time, Time._DESERIALIZER, "time"); op.add(Builder::timeInMillis, JsonpDeserializer.longDeserializer(), "time_in_millis"); op.add(Builder::total, FileCountSnapshotStats._DESERIALIZER, "total"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.incremental.hashCode(); + result = 31 * result + Objects.hashCode(this.processed); + result = 31 * result + Long.hashCode(this.startTimeInMillis); + result = 31 * result + Objects.hashCode(this.time); + result = 31 * result + Long.hashCode(this.timeInMillis); + result = 31 * result + this.total.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotStats other = (SnapshotStats) o; + return this.incremental.equals(other.incremental) + && Objects.equals(this.processed, other.processed) + && this.startTimeInMillis == other.startTimeInMillis + && Objects.equals(this.time, other.time) + && this.timeInMillis == other.timeInMillis + && this.total.equals(other.total); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/Status.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStatus.java similarity index 58% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/Status.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStatus.java index 03992f5175..14324149a4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/Status.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStatus.java @@ -30,11 +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.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; import org.opensearch.client.json.JsonpMapper; @@ -42,34 +50,45 @@ 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.Status +// typedef: snapshot.SnapshotStatus @JsonpDeserializable -public class Status implements PlainJsonSerializable { - private final boolean includeGlobalState; +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotStatus implements PlainJsonSerializable, ToCopyableBuilder { + + @Nullable + private final Boolean includeGlobalState; + @Nonnull private final Map indices; + @Nonnull private final String repository; - private final ShardsStats shardsStats; + @Nonnull + private final SnapshotShardsStats shardsStats; + @Nonnull private final String snapshot; + @Nonnull private final String state; + @Nonnull private final SnapshotStats stats; + @Nonnull private final String uuid; // --------------------------------------------------------------------------------------------- - private Status(Builder builder) { - - this.includeGlobalState = ApiTypeHelper.requireNonNull(builder.includeGlobalState, this, "includeGlobalState"); + private SnapshotStatus(Builder builder) { + this.includeGlobalState = builder.includeGlobalState; this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository"); this.shardsStats = ApiTypeHelper.requireNonNull(builder.shardsStats, this, "shardsStats"); @@ -77,23 +96,24 @@ private Status(Builder builder) { this.state = ApiTypeHelper.requireNonNull(builder.state, this, "state"); this.stats = ApiTypeHelper.requireNonNull(builder.stats, this, "stats"); this.uuid = ApiTypeHelper.requireNonNull(builder.uuid, this, "uuid"); - } - public static Status of(Function> fn) { + public static SnapshotStatus of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Required - API name: {@code include_global_state} + * API name: {@code include_global_state} */ - public final boolean includeGlobalState() { + @Nullable + public final Boolean includeGlobalState() { return this.includeGlobalState; } /** * Required - API name: {@code indices} */ + @Nonnull public final Map indices() { return this.indices; } @@ -101,6 +121,7 @@ public final Map indices() { /** * Required - API name: {@code repository} */ + @Nonnull public final String repository() { return this.repository; } @@ -108,13 +129,15 @@ public final String repository() { /** * Required - API name: {@code shards_stats} */ - public final ShardsStats shardsStats() { + @Nonnull + public final SnapshotShardsStats shardsStats() { return this.shardsStats; } /** * Required - API name: {@code snapshot} */ + @Nonnull public final String snapshot() { return this.snapshot; } @@ -122,6 +145,7 @@ public final String snapshot() { /** * Required - API name: {@code state} */ + @Nonnull public final String state() { return this.state; } @@ -129,6 +153,7 @@ public final String state() { /** * Required - API name: {@code stats} */ + @Nonnull public final SnapshotStats stats() { return this.stats; } @@ -136,6 +161,7 @@ public final SnapshotStats stats() { /** * Required - API name: {@code uuid} */ + @Nonnull public final String uuid() { return this.uuid; } @@ -143,6 +169,7 @@ public final String uuid() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -150,21 +177,19 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.includeGlobalState != null) { + generator.writeKey("include_global_state"); + generator.write(this.includeGlobalState); + } - generator.writeKey("include_global_state"); - generator.write(this.includeGlobalState); - - if (ApiTypeHelper.isDefined(this.indices)) { - generator.writeKey("indices"); - generator.writeStartObject(); - for (Map.Entry item0 : this.indices.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - + generator.writeKey("indices"); + generator.writeStartObject(); + for (Map.Entry item0 : this.indices.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); } + generator.writeEnd(); + generator.writeKey("repository"); generator.write(this.repository); @@ -182,45 +207,82 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("uuid"); generator.write(this.uuid); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** - * Builder for {@link Status}. + * Builder for {@link SnapshotStatus}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable private Boolean includeGlobalState; - private Map indices; - private String repository; - - private ShardsStats shardsStats; - + private SnapshotShardsStats shardsStats; private String snapshot; - private String state; - private SnapshotStats stats; - private String uuid; + public Builder() {} + + private Builder(SnapshotStatus o) { + this.includeGlobalState = o.includeGlobalState; + this.indices = _mapCopy(o.indices); + this.repository = o.repository; + this.shardsStats = o.shardsStats; + this.snapshot = o.snapshot; + this.state = o.state; + this.stats = o.stats; + this.uuid = o.uuid; + } + + private Builder(Builder o) { + this.includeGlobalState = o.includeGlobalState; + this.indices = _mapCopy(o.indices); + this.repository = o.repository; + this.shardsStats = o.shardsStats; + this.snapshot = o.snapshot; + this.state = o.state; + this.stats = o.stats; + this.uuid = o.uuid; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** - * Required - API name: {@code include_global_state} + * API name: {@code include_global_state} */ - public final Builder includeGlobalState(boolean value) { + @Nonnull + public final Builder includeGlobalState(@Nullable Boolean value) { this.includeGlobalState = value; return this; } /** * Required - API name: {@code indices} + * *

- * Adds all entries of map to indices. + * Adds all elements of map to indices. + *

*/ + @Nonnull public final Builder indices(Map map) { this.indices = _mapPutAll(this.indices, map); return this; @@ -228,9 +290,12 @@ public final Builder indices(Map map) { /** * Required - API name: {@code indices} + * *

* Adds an entry to indices. + *

*/ + @Nonnull public final Builder indices(String key, SnapshotIndexStats value) { this.indices = _mapPut(this.indices, key, value); return this; @@ -238,9 +303,12 @@ public final Builder indices(String key, SnapshotIndexStats value) { /** * Required - API name: {@code indices} + * *

- * Adds an entry to indices using a builder lambda. + * Adds a value to indices using a builder lambda. + *

*/ + @Nonnull public final Builder indices(String key, Function> fn) { return indices(key, fn.apply(new SnapshotIndexStats.Builder()).build()); } @@ -248,6 +316,7 @@ public final Builder indices(String key, Function> fn) { - return this.shardsStats(fn.apply(new ShardsStats.Builder()).build()); + @Nonnull + public final Builder shardsStats(Function> fn) { + return shardsStats(fn.apply(new SnapshotShardsStats.Builder()).build()); } /** * Required - API name: {@code snapshot} */ + @Nonnull public final Builder snapshot(String value) { this.snapshot = value; return this; @@ -279,6 +351,7 @@ public final Builder snapshot(String value) { /** * Required - API name: {@code state} */ + @Nonnull public final Builder state(String value) { this.state = value; return this; @@ -287,6 +360,7 @@ public final Builder state(String value) { /** * Required - API name: {@code stats} */ + @Nonnull public final Builder stats(SnapshotStats value) { this.stats = value; return this; @@ -295,52 +369,81 @@ public final Builder stats(SnapshotStats value) { /** * Required - API name: {@code stats} */ + @Nonnull public final Builder stats(Function> fn) { - return this.stats(fn.apply(new SnapshotStats.Builder()).build()); + return stats(fn.apply(new SnapshotStats.Builder()).build()); } /** * Required - API name: {@code uuid} */ + @Nonnull public final Builder uuid(String value) { this.uuid = value; return this; } /** - * Builds a {@link Status}. + * Builds a {@link SnapshotStatus}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ - public Status build() { + @Override + @Nonnull + public SnapshotStatus build() { _checkSingleUse(); - return new Status(this); + return new SnapshotStatus(this); } } // --------------------------------------------------------------------------------------------- /** - * Json deserializer for {@link Status} + * Json deserializer for {@link SnapshotStatus} */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( Builder::new, - Status::setupStatusDeserializer + SnapshotStatus::setupSnapshotStatusDeserializer ); - protected static void setupStatusDeserializer(ObjectDeserializer op) { - + protected static void setupSnapshotStatusDeserializer(ObjectDeserializer op) { op.add(Builder::includeGlobalState, JsonpDeserializer.booleanDeserializer(), "include_global_state"); op.add(Builder::indices, JsonpDeserializer.stringMapDeserializer(SnapshotIndexStats._DESERIALIZER), "indices"); op.add(Builder::repository, JsonpDeserializer.stringDeserializer(), "repository"); - op.add(Builder::shardsStats, ShardsStats._DESERIALIZER, "shards_stats"); + op.add(Builder::shardsStats, SnapshotShardsStats._DESERIALIZER, "shards_stats"); op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); op.add(Builder::state, JsonpDeserializer.stringDeserializer(), "state"); op.add(Builder::stats, SnapshotStats._DESERIALIZER, "stats"); op.add(Builder::uuid, JsonpDeserializer.stringDeserializer(), "uuid"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.includeGlobalState); + result = 31 * result + this.indices.hashCode(); + result = 31 * result + this.repository.hashCode(); + result = 31 * result + this.shardsStats.hashCode(); + result = 31 * result + this.snapshot.hashCode(); + result = 31 * result + this.state.hashCode(); + result = 31 * result + this.stats.hashCode(); + result = 31 * result + this.uuid.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotStatus other = (SnapshotStatus) o; + return Objects.equals(this.includeGlobalState, other.includeGlobalState) + && this.indices.equals(other.indices) + && this.repository.equals(other.repository) + && this.shardsStats.equals(other.shardsStats) + && this.snapshot.equals(other.snapshot) + && this.state.equals(other.state) + && this.stats.equals(other.stats) + && this.uuid.equals(other.uuid); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusRequest.java similarity index 68% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusRequest.java index 1e0a59dfe1..9de668e4ac 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusRequest.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,17 +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.status.Request /** * Returns information about the status of a snapshot. - * */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotStatusRequest extends RequestBase implements ToCopyableBuilder { + + @Nullable + private final Time clusterManagerTimeout; -public class SnapshotStatusRequest extends RequestBase { @Nullable private final Boolean ignoreUnavailable; @@ -62,66 +73,65 @@ public class SnapshotStatusRequest extends RequestBase { @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - @Nullable private final String repository; + @Nonnull private final List snapshot; // --------------------------------------------------------------------------------------------- private SnapshotStatusRequest(Builder builder) { - + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.ignoreUnavailable = builder.ignoreUnavailable; this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.repository = builder.repository; this.snapshot = ApiTypeHelper.unmodifiable(builder.snapshot); - } - public static SnapshotStatusRequest of(Function> fn) { + public static SnapshotStatusRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Whether to ignore unavailable snapshots, defaults to false which means a - * SnapshotMissingException is thrown + * Operation timeout for connection to cluster-manager node. *

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

*/ @Nullable - public final Boolean ignoreUnavailable() { - return this.ignoreUnavailable; + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; } /** - * Explicit operation timeout for connection to master node + * Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown *

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

*/ - @Deprecated @Nullable - public final Time masterTimeout() { - return this.masterTimeout; + public final Boolean ignoreUnavailable() { + return this.ignoreUnavailable; } /** * 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 repository name *

* API name: {@code repository} + *

*/ @Nullable public final String repository() { @@ -132,90 +142,132 @@ public final String repository() { * A comma-separated list of snapshot names *

* API name: {@code snapshot} + *

*/ + @Nonnull public final List snapshot() { return this.snapshot; } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link SnapshotStatusRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private Time clusterManagerTimeout; @Nullable private Boolean ignoreUnavailable; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - @Nullable private String repository; - @Nullable private List snapshot; + public Builder() {} + + private Builder(SnapshotStatusRequest o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.ignoreUnavailable = o.ignoreUnavailable; + this.masterTimeout = o.masterTimeout; + this.repository = o.repository; + this.snapshot = _listCopy(o.snapshot); + } + + private Builder(Builder o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.ignoreUnavailable = o.ignoreUnavailable; + this.masterTimeout = o.masterTimeout; + this.repository = o.repository; + this.snapshot = _listCopy(o.snapshot); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** - * Whether to ignore unavailable snapshots, defaults to false which means a - * SnapshotMissingException is thrown + * Operation timeout for connection to cluster-manager node. *

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

*/ - public final Builder ignoreUnavailable(@Nullable Boolean value) { - this.ignoreUnavailable = 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 + * Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown *

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

*/ - @Deprecated - public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); + @Nonnull + public final Builder ignoreUnavailable(@Nullable Boolean value) { + this.ignoreUnavailable = 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 repository name *

* API name: {@code repository} + *

*/ + @Nonnull public final Builder repository(@Nullable String value) { this.repository = value; return this; @@ -225,9 +277,13 @@ public final Builder repository(@Nullable String value) { * A comma-separated list of snapshot names *

* API name: {@code snapshot} + *

+ * *

* Adds all elements of list to snapshot. + *

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

* API name: {@code snapshot} + *

+ * *

* Adds one or more values to snapshot. + *

*/ + @Nonnull public final Builder snapshot(String value, String... values) { this.snapshot = _listAdd(this.snapshot, value, values); return this; @@ -248,9 +308,10 @@ public final Builder snapshot(String value, String... values) { /** * Builds a {@link SnapshotStatusRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public SnapshotStatusRequest build() { _checkSingleUse(); @@ -264,13 +325,8 @@ public SnapshotStatusRequest build() { * Endpoint "{@code snapshot.status}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // Request path request -> { final int _repository = 1 << 0; @@ -282,50 +338,66 @@ public SnapshotStatusRequest build() { if (ApiTypeHelper.isDefined(request.snapshot())) propsSet |= _snapshot; if (propsSet == 0) { - StringBuilder buf = new StringBuilder(); - buf.append("/_snapshot"); - buf.append("/_status"); - return buf.toString(); + return "/_snapshot/_status"; } if (propsSet == (_repository)) { StringBuilder buf = new StringBuilder(); - buf.append("/_snapshot"); - buf.append("/"); + buf.append("/_snapshot/"); SimpleEndpoint.pathEncode(request.repository, buf); buf.append("/_status"); return buf.toString(); } if (propsSet == (_repository | _snapshot)) { StringBuilder buf = new StringBuilder(); - buf.append("/_snapshot"); - buf.append("/"); + buf.append("/_snapshot/"); SimpleEndpoint.pathEncode(request.repository, buf); buf.append("/"); - SimpleEndpoint.pathEncode(request.snapshot.stream().map(v -> v).collect(Collectors.joining(",")), buf); + SimpleEndpoint.pathEncode(String.join(",", request.snapshot), buf); buf.append("/_status"); 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.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } return params; - }, SimpleEndpoint.emptyMap(), false, SnapshotStatusResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + Objects.hashCode(this.repository); + result = 31 * result + Objects.hashCode(this.snapshot); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotStatusRequest other = (SnapshotStatusRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.repository, other.repository) + && Objects.equals(this.snapshot, other.snapshot); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusResponse.java similarity index 60% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusResponse.java index e97f02540d..6be7b25971 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotStatusResponse.java @@ -30,11 +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.List; 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.JsonpMapper; @@ -42,37 +48,45 @@ 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.status.Response @JsonpDeserializable -public class SnapshotStatusResponse implements PlainJsonSerializable { - private final List snapshots; +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotStatusResponse + implements + PlainJsonSerializable, + ToCopyableBuilder { + + @Nonnull + private final List snapshots; // --------------------------------------------------------------------------------------------- private SnapshotStatusResponse(Builder builder) { - this.snapshots = ApiTypeHelper.unmodifiableRequired(builder.snapshots, this, "snapshots"); - } - public static SnapshotStatusResponse of(Function> fn) { + public static SnapshotStatusResponse of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code snapshots} */ - public final List snapshots() { + @Nonnull + public final List snapshots() { return this.snapshots; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -80,64 +94,94 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.snapshots)) { - generator.writeKey("snapshots"); - generator.writeStartArray(); - for (Status item0 : this.snapshots) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - + generator.writeKey("snapshots"); + generator.writeStartArray(); + for (SnapshotStatus item0 : this.snapshots) { + item0.serialize(generator, mapper); } - + generator.writeEnd(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link SnapshotStatusResponse}. */ + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + private List snapshots; - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private List snapshots; + public Builder() {} + + private Builder(SnapshotStatusResponse o) { + this.snapshots = _listCopy(o.snapshots); + } + + private Builder(Builder o) { + this.snapshots = _listCopy(o.snapshots); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } /** * Required - API name: {@code snapshots} + * *

* Adds all elements of list to snapshots. + *

*/ - public final Builder snapshots(List list) { + @Nonnull + public final Builder snapshots(List list) { this.snapshots = _listAddAll(this.snapshots, list); return this; } /** * Required - API name: {@code snapshots} + * *

* Adds one or more values to snapshots. + *

*/ - public final Builder snapshots(Status value, Status... values) { + @Nonnull + public final Builder snapshots(SnapshotStatus value, SnapshotStatus... values) { this.snapshots = _listAdd(this.snapshots, value, values); return this; } /** * Required - API name: {@code snapshots} + * *

* Adds a value to snapshots using a builder lambda. + *

*/ - public final Builder snapshots(Function> fn) { - return snapshots(fn.apply(new Status.Builder()).build()); + @Nonnull + public final Builder snapshots(Function> fn) { + return snapshots(fn.apply(new SnapshotStatus.Builder()).build()); } /** * Builds a {@link SnapshotStatusResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public SnapshotStatusResponse build() { _checkSingleUse(); @@ -156,9 +200,21 @@ public SnapshotStatusResponse build() { ); protected static void setupSnapshotStatusResponseDeserializer(ObjectDeserializer op) { + op.add(Builder::snapshots, JsonpDeserializer.arrayDeserializer(SnapshotStatus._DESERIALIZER), "snapshots"); + } - op.add(Builder::snapshots, JsonpDeserializer.arrayDeserializer(Status._DESERIALIZER), "snapshots"); - + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.snapshots.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotStatusResponse other = (SnapshotStatusResponse) o; + return this.snapshots.equals(other.snapshots); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/restore/SnapshotRestore.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/restore/SnapshotRestore.java similarity index 69% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/restore/SnapshotRestore.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/restore/SnapshotRestore.java index 26a6982644..b0828e1555 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/restore/SnapshotRestore.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/restore/SnapshotRestore.java @@ -30,11 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.snapshot.restore; import jakarta.json.stream.JsonGenerator; import java.util.List; 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.JsonpMapper; @@ -43,57 +49,66 @@ import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.opensearch._types.ShardStatistics; 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.restore.SnapshotRestore @JsonpDeserializable -public class SnapshotRestore implements PlainJsonSerializable { - private final List indices; +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotRestore implements PlainJsonSerializable, ToCopyableBuilder { - private final String snapshot; + @Nonnull + private final List indices; + @Nonnull private final ShardStatistics shards; + @Nonnull + private final String snapshot; + // --------------------------------------------------------------------------------------------- private SnapshotRestore(Builder builder) { - this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); - this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards"); - + this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); } - public static SnapshotRestore of(Function> fn) { + public static SnapshotRestore of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code indices} */ + @Nonnull public final List indices() { return this.indices; } /** - * Required - API name: {@code snapshot} + * Required - API name: {@code shards} */ - public final String snapshot() { - return this.snapshot; + @Nonnull + public final ShardStatistics shards() { + return this.shards; } /** - * Required - API name: {@code shards} + * Required - API name: {@code snapshot} */ - public final ShardStatistics shards() { - return this.shards; + @Nonnull + public final String snapshot() { + return this.snapshot; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -101,43 +116,69 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.indices)) { - generator.writeKey("indices"); - generator.writeStartArray(); - for (String item0 : this.indices) { - generator.write(item0); - - } - generator.writeEnd(); - + generator.writeKey("indices"); + generator.writeStartArray(); + for (String item0 : this.indices) { + generator.write(item0); } - generator.writeKey("snapshot"); - generator.write(this.snapshot); + generator.writeEnd(); generator.writeKey("shards"); this.shards.serialize(generator, mapper); + generator.writeKey("snapshot"); + generator.write(this.snapshot); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link SnapshotRestore}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private List indices; - + private ShardStatistics shards; private String snapshot; - private ShardStatistics shards; + public Builder() {} + + private Builder(SnapshotRestore o) { + this.indices = _listCopy(o.indices); + this.shards = o.shards; + this.snapshot = o.snapshot; + } + + private Builder(Builder o) { + this.indices = _listCopy(o.indices); + this.shards = o.shards; + this.snapshot = o.snapshot; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } /** * Required - API name: {@code indices} + * *

* Adds all elements of list to indices. + *

*/ + @Nonnull public final Builder indices(List list) { this.indices = _listAddAll(this.indices, list); return this; @@ -145,25 +186,21 @@ public final Builder indices(List list) { /** * Required - API name: {@code indices} + * *

* Adds one or more values to indices. + *

*/ + @Nonnull public final Builder indices(String value, String... values) { this.indices = _listAdd(this.indices, value, values); return this; } - /** - * Required - API name: {@code snapshot} - */ - public final Builder snapshot(String value) { - this.snapshot = value; - return this; - } - /** * Required - API name: {@code shards} */ + @Nonnull public final Builder shards(ShardStatistics value) { this.shards = value; return this; @@ -172,16 +209,27 @@ public final Builder shards(ShardStatistics value) { /** * Required - API name: {@code shards} */ + @Nonnull public final Builder shards(Function> fn) { - return this.shards(fn.apply(new ShardStatistics.Builder()).build()); + return shards(fn.apply(new ShardStatistics.Builder()).build()); + } + + /** + * Required - API name: {@code snapshot} + */ + @Nonnull + public final Builder snapshot(String value) { + this.snapshot = value; + return this; } /** * Builds a {@link SnapshotRestore}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public SnapshotRestore build() { _checkSingleUse(); @@ -200,11 +248,25 @@ public SnapshotRestore build() { ); protected static void setupSnapshotRestoreDeserializer(ObjectDeserializer op) { - op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); - op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); op.add(Builder::shards, ShardStatistics._DESERIALIZER, "shards"); + op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.indices.hashCode(); + result = 31 * result + this.shards.hashCode(); + result = 31 * result + this.snapshot.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotRestore other = (SnapshotRestore) o; + return this.indices.equals(other.indices) && this.shards.equals(other.shards) && this.snapshot.equals(other.snapshot); + } } 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 deleted file mode 100644 index 86e3016d6b..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * 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. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.snapshot; - -import java.io.IOException; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.opensearch._types.ErrorResponse; -import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; -import org.opensearch.client.transport.OpenSearchTransport; -import org.opensearch.client.transport.TransportOptions; -import org.opensearch.client.util.ObjectBuilder; - -/** - * Client for the snapshot namespace. - */ -public class OpenSearchSnapshotAsyncClient extends OpenSearchSnapshotAsyncClientBase { - - public OpenSearchSnapshotAsyncClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchSnapshotAsyncClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchSnapshotAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchSnapshotAsyncClient(this.transport, transportOptions); - } - - // ----- Endpoint: snapshot.create - - /** - * Creates a snapshot in a repository. - * - * - */ - - public CompletableFuture create(CreateSnapshotRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - CreateSnapshotRequest, - CreateSnapshotResponse, - ErrorResponse>) CreateSnapshotRequest._ENDPOINT; - - 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 - - /** - * Deletes a snapshot. - * - * - */ - - public CompletableFuture delete(DeleteSnapshotRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteSnapshotRequest, - DeleteSnapshotResponse, - ErrorResponse>) DeleteSnapshotRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Deletes a snapshot. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteSnapshotRequest} - * - */ - - public final CompletableFuture delete( - Function> fn - ) throws IOException, OpenSearchException { - 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 - - /** - * Restores a snapshot. - * - * - */ - - public CompletableFuture restore(RestoreRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - RestoreRequest, - RestoreResponse, - ErrorResponse>) RestoreRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Restores a snapshot. - * - * @param fn - * a function that initializes a builder to create the - * {@link RestoreRequest} - * - */ - - public final CompletableFuture restore(Function> fn) - throws IOException, OpenSearchException { - return restore(fn.apply(new RestoreRequest.Builder()).build()); - } - - // ----- Endpoint: snapshot.status - - /** - * Returns information about the status of a snapshot. - * - * - */ - - public CompletableFuture status(SnapshotStatusRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - SnapshotStatusRequest, - SnapshotStatusResponse, - ErrorResponse>) SnapshotStatusRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about the status of a snapshot. - * - * @param fn - * a function that initializes a builder to create the - * {@link SnapshotStatusRequest} - * - */ - - public final CompletableFuture status( - Function> fn - ) throws IOException, OpenSearchException { - return status(fn.apply(new SnapshotStatusRequest.Builder()).build()); - } - - /** - * Returns information about the status of a snapshot. - * - * - */ - - public CompletableFuture status() throws IOException, OpenSearchException { - return this.transport.performRequestAsync( - new SnapshotStatusRequest.Builder().build(), - SnapshotStatusRequest._ENDPOINT, - this.transportOptions - ); - } -} 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 deleted file mode 100644 index e80cf77ee8..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * 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. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.snapshot; - -import java.io.IOException; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.opensearch._types.ErrorResponse; -import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; -import org.opensearch.client.transport.OpenSearchTransport; -import org.opensearch.client.transport.TransportOptions; -import org.opensearch.client.util.ObjectBuilder; - -/** - * Client for the snapshot namespace. - */ -public class OpenSearchSnapshotClient extends OpenSearchSnapshotClientBase { - - public OpenSearchSnapshotClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchSnapshotClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchSnapshotClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchSnapshotClient(this.transport, transportOptions); - } - - // ----- Endpoint: snapshot.create - - /** - * Creates a snapshot in a repository. - * - * - */ - - public CreateSnapshotResponse create(CreateSnapshotRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - CreateSnapshotRequest, - CreateSnapshotResponse, - ErrorResponse>) CreateSnapshotRequest._ENDPOINT; - - 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 - - /** - * Deletes a snapshot. - * - * - */ - - public DeleteSnapshotResponse delete(DeleteSnapshotRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteSnapshotRequest, - DeleteSnapshotResponse, - ErrorResponse>) DeleteSnapshotRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Deletes a snapshot. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteSnapshotRequest} - * - */ - - public final DeleteSnapshotResponse delete(Function> fn) - throws IOException, OpenSearchException { - return delete(fn.apply(new DeleteSnapshotRequest.Builder()).build()); - } - - // ----- Endpoint: snapshot.delete_repository - - /** - * Deletes a repository. - * - * - */ - - public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint 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 - - /** - * Restores a snapshot. - * - * - */ - - public RestoreResponse restore(RestoreRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - RestoreRequest, - RestoreResponse, - ErrorResponse>) RestoreRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Restores a snapshot. - * - * @param fn - * a function that initializes a builder to create the - * {@link RestoreRequest} - * - */ - - public final RestoreResponse restore(Function> fn) throws IOException, - OpenSearchException { - return restore(fn.apply(new RestoreRequest.Builder()).build()); - } - - // ----- Endpoint: snapshot.status - - /** - * Returns information about the status of a snapshot. - * - * - */ - - public SnapshotStatusResponse status(SnapshotStatusRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - SnapshotStatusRequest, - SnapshotStatusResponse, - ErrorResponse>) SnapshotStatusRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about the status of a snapshot. - * - * @param fn - * a function that initializes a builder to create the - * {@link SnapshotStatusRequest} - * - */ - - public final SnapshotStatusResponse status(Function> fn) - throws IOException, OpenSearchException { - return status(fn.apply(new SnapshotStatusRequest.Builder()).build()); - } - - /** - * Returns information about the status of a snapshot. - * - * - */ - - public SnapshotStatusResponse status() throws IOException, OpenSearchException { - return this.transport.performRequest( - new SnapshotStatusRequest.Builder().build(), - SnapshotStatusRequest._ENDPOINT, - this.transportOptions - ); - } -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/RestoreRequest.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/RestoreRequest.java deleted file mode 100644 index 1e6754e8aa..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/RestoreRequest.java +++ /dev/null @@ -1,634 +0,0 @@ -/* - * 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. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.snapshot; - -import jakarta.json.stream.JsonGenerator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.opensearch._types.ErrorResponse; -import org.opensearch.client.opensearch._types.RequestBase; -import org.opensearch.client.opensearch._types.Time; -import org.opensearch.client.opensearch.indices.PutIndicesSettingsRequest; -import org.opensearch.client.transport.Endpoint; -import org.opensearch.client.transport.endpoints.SimpleEndpoint; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: snapshot.restore.Request - -/** - * Restores a snapshot. - */ -@JsonpDeserializable -public class RestoreRequest extends RequestBase implements PlainJsonSerializable { - private final List ignoreIndexSettings; - - @Nullable - private final Boolean ignoreUnavailable; - - @Nullable - private final Boolean includeAliases; - - @Nullable - private final Boolean includeGlobalState; - - @Nullable - private final PutIndicesSettingsRequest indexSettings; - - private final List indices; - - @Deprecated - @Nullable - private final Time masterTimeout; - - @Nullable - private final Time clusterManagerTimeout; - - @Nullable - private final Boolean partial; - - @Nullable - private final String renamePattern; - - @Nullable - private final String renameReplacement; - - private final String repository; - - private final String snapshot; - - @Nullable - private final Boolean waitForCompletion; - - // --------------------------------------------------------------------------------------------- - - private RestoreRequest(Builder builder) { - - this.ignoreIndexSettings = ApiTypeHelper.unmodifiable(builder.ignoreIndexSettings); - this.ignoreUnavailable = builder.ignoreUnavailable; - this.includeAliases = builder.includeAliases; - this.includeGlobalState = builder.includeGlobalState; - this.indexSettings = builder.indexSettings; - this.indices = ApiTypeHelper.unmodifiable(builder.indices); - this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.partial = builder.partial; - this.renamePattern = builder.renamePattern; - this.renameReplacement = builder.renameReplacement; - this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository"); - this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); - this.waitForCompletion = builder.waitForCompletion; - - } - - public static RestoreRequest of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * API name: {@code ignore_index_settings} - */ - public final List ignoreIndexSettings() { - return this.ignoreIndexSettings; - } - - /** - * API name: {@code ignore_unavailable} - */ - @Nullable - public final Boolean ignoreUnavailable() { - return this.ignoreUnavailable; - } - - /** - * API name: {@code include_aliases} - */ - @Nullable - public final Boolean includeAliases() { - return this.includeAliases; - } - - /** - * API name: {@code include_global_state} - */ - @Nullable - public final Boolean includeGlobalState() { - return this.includeGlobalState; - } - - /** - * API name: {@code index_settings} - */ - @Nullable - public final PutIndicesSettingsRequest indexSettings() { - return this.indexSettings; - } - - /** - * API name: {@code indices} - */ - public final List indices() { - return this.indices; - } - - /** - * Explicit operation timeout for connection to master node - *

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

- * API name: {@code cluster_manager_timeout} - */ - @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - /** - * API name: {@code partial} - */ - @Nullable - public final Boolean partial() { - return this.partial; - } - - /** - * API name: {@code rename_pattern} - */ - @Nullable - public final String renamePattern() { - return this.renamePattern; - } - - /** - * API name: {@code rename_replacement} - */ - @Nullable - public final String renameReplacement() { - return this.renameReplacement; - } - - /** - * Required - A repository name - *

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

- * API name: {@code snapshot} - */ - public final String snapshot() { - return this.snapshot; - } - - /** - * Should this request wait until the operation has completed before returning - *

- * API name: {@code wait_for_completion} - */ - @Nullable - public final Boolean waitForCompletion() { - return this.waitForCompletion; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.ignoreIndexSettings)) { - generator.writeKey("ignore_index_settings"); - generator.writeStartArray(); - for (String item0 : this.ignoreIndexSettings) { - generator.write(item0); - - } - generator.writeEnd(); - - } - if (this.ignoreUnavailable != null) { - generator.writeKey("ignore_unavailable"); - generator.write(this.ignoreUnavailable); - - } - if (this.includeAliases != null) { - generator.writeKey("include_aliases"); - generator.write(this.includeAliases); - - } - if (this.includeGlobalState != null) { - generator.writeKey("include_global_state"); - generator.write(this.includeGlobalState); - - } - if (this.indexSettings != null) { - generator.writeKey("index_settings"); - this.indexSettings.serialize(generator, mapper); - - } - if (ApiTypeHelper.isDefined(this.indices)) { - generator.writeKey("indices"); - generator.writeStartArray(); - for (String item0 : this.indices) { - generator.write(item0); - - } - generator.writeEnd(); - - } - if (this.partial != null) { - generator.writeKey("partial"); - generator.write(this.partial); - - } - if (this.renamePattern != null) { - generator.writeKey("rename_pattern"); - generator.write(this.renamePattern); - - } - if (this.renameReplacement != null) { - generator.writeKey("rename_replacement"); - generator.write(this.renameReplacement); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link RestoreRequest}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private List ignoreIndexSettings; - - @Nullable - private Boolean ignoreUnavailable; - - @Nullable - private Boolean includeAliases; - - @Nullable - private Boolean includeGlobalState; - - @Nullable - private PutIndicesSettingsRequest indexSettings; - - @Nullable - private List indices; - - @Deprecated - @Nullable - private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - - @Nullable - private Boolean partial; - - @Nullable - private String renamePattern; - - @Nullable - private String renameReplacement; - - private String repository; - - private String snapshot; - - @Nullable - private Boolean waitForCompletion; - - /** - * API name: {@code ignore_index_settings} - *

- * Adds all elements of list to ignoreIndexSettings. - */ - public final Builder ignoreIndexSettings(List list) { - this.ignoreIndexSettings = _listAddAll(this.ignoreIndexSettings, list); - return this; - } - - /** - * API name: {@code ignore_index_settings} - *

- * Adds one or more values to ignoreIndexSettings. - */ - public final Builder ignoreIndexSettings(String value, String... values) { - this.ignoreIndexSettings = _listAdd(this.ignoreIndexSettings, value, values); - return this; - } - - /** - * API name: {@code ignore_unavailable} - */ - public final Builder ignoreUnavailable(@Nullable Boolean value) { - this.ignoreUnavailable = value; - return this; - } - - /** - * API name: {@code include_aliases} - */ - public final Builder includeAliases(@Nullable Boolean value) { - this.includeAliases = value; - return this; - } - - /** - * API name: {@code include_global_state} - */ - public final Builder includeGlobalState(@Nullable Boolean value) { - this.includeGlobalState = value; - return this; - } - - /** - * API name: {@code index_settings} - */ - public final Builder indexSettings(@Nullable PutIndicesSettingsRequest value) { - this.indexSettings = value; - return this; - } - - /** - * API name: {@code index_settings} - */ - public final Builder indexSettings(Function> fn) { - return this.indexSettings(fn.apply(new PutIndicesSettingsRequest.Builder()).build()); - } - - /** - * API name: {@code indices} - *

- * Adds all elements of list to indices. - */ - public final Builder indices(List list) { - this.indices = _listAddAll(this.indices, list); - return this; - } - - /** - * API name: {@code indices} - *

- * Adds one or more values to indices. - */ - public final Builder indices(String value, String... values) { - this.indices = _listAdd(this.indices, value, values); - return this; - } - - /** - * Explicit operation timeout for connection to master node - *

- * API name: {@code master_timeout} - */ - @Deprecated - public final Builder masterTimeout(@Nullable Time value) { - this.masterTimeout = value; - return this; - } - - /** - * Explicit operation timeout for connection to master node - *

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

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

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * API name: {@code partial} - */ - public final Builder partial(@Nullable Boolean value) { - this.partial = value; - return this; - } - - /** - * API name: {@code rename_pattern} - */ - public final Builder renamePattern(@Nullable String value) { - this.renamePattern = value; - return this; - } - - /** - * API name: {@code rename_replacement} - */ - public final Builder renameReplacement(@Nullable String value) { - this.renameReplacement = value; - return this; - } - - /** - * Required - A repository name - *

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

- * API name: {@code snapshot} - */ - public final Builder snapshot(String value) { - this.snapshot = value; - return this; - } - - /** - * Should this request wait until the operation has completed before returning - *

- * API name: {@code wait_for_completion} - */ - public final Builder waitForCompletion(@Nullable Boolean value) { - this.waitForCompletion = value; - return this; - } - - /** - * Builds a {@link RestoreRequest}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public RestoreRequest build() { - _checkSingleUse(); - - return new RestoreRequest(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link RestoreRequest} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - RestoreRequest::setupRestoreRequestDeserializer - ); - - protected static void setupRestoreRequestDeserializer(ObjectDeserializer op) { - - op.add( - Builder::ignoreIndexSettings, - JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), - "ignore_index_settings" - ); - op.add(Builder::ignoreUnavailable, JsonpDeserializer.booleanDeserializer(), "ignore_unavailable"); - op.add(Builder::includeAliases, JsonpDeserializer.booleanDeserializer(), "include_aliases"); - op.add(Builder::includeGlobalState, JsonpDeserializer.booleanDeserializer(), "include_global_state"); - op.add(Builder::indexSettings, PutIndicesSettingsRequest._DESERIALIZER, "index_settings"); - op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); - op.add(Builder::partial, JsonpDeserializer.booleanDeserializer(), "partial"); - op.add(Builder::renamePattern, JsonpDeserializer.stringDeserializer(), "rename_pattern"); - op.add(Builder::renameReplacement, JsonpDeserializer.stringDeserializer(), "rename_replacement"); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Endpoint "{@code snapshot.restore}". - */ - public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - - // Request method - request -> { - return "POST"; - - }, - - // Request path - request -> { - final int _repository = 1 << 0; - final int _snapshot = 1 << 1; - - int propsSet = 0; - - propsSet |= _repository; - propsSet |= _snapshot; - - if (propsSet == (_repository | _snapshot)) { - StringBuilder buf = new StringBuilder(); - buf.append("/_snapshot"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.repository, buf); - buf.append("/"); - SimpleEndpoint.pathEncode(request.snapshot, buf); - buf.append("/_restore"); - return buf.toString(); - } - 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.waitForCompletion != null) { - params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); - } - return params; - - }, - SimpleEndpoint.emptyMap(), - true, - RestoreResponse._DESERIALIZER - ); -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/RestoreResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/RestoreResponse.java deleted file mode 100644 index 2791c31793..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/RestoreResponse.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.snapshot; - -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.opensearch.snapshot.restore.SnapshotRestore; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: snapshot.restore.Response - -@JsonpDeserializable -public class RestoreResponse implements PlainJsonSerializable { - private final SnapshotRestore snapshot; - - // --------------------------------------------------------------------------------------------- - - private RestoreResponse(Builder builder) { - - this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); - - } - - public static RestoreResponse of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code snapshot} - */ - public final SnapshotRestore snapshot() { - return this.snapshot; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("snapshot"); - this.snapshot.serialize(generator, mapper); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link RestoreResponse}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private SnapshotRestore snapshot; - - /** - * Required - API name: {@code snapshot} - */ - public final Builder snapshot(SnapshotRestore value) { - this.snapshot = value; - return this; - } - - /** - * Required - API name: {@code snapshot} - */ - public final Builder snapshot(Function> fn) { - return this.snapshot(fn.apply(new SnapshotRestore.Builder()).build()); - } - - /** - * Builds a {@link RestoreResponse}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public RestoreResponse build() { - _checkSingleUse(); - - return new RestoreResponse(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link RestoreResponse} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - RestoreResponse::setupRestoreResponseDeserializer - ); - - protected static void setupRestoreResponseDeserializer(ObjectDeserializer op) { - - op.add(Builder::snapshot, SnapshotRestore._DESERIALIZER, "snapshot"); - - } - -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStatsSummary.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStatsSummary.java deleted file mode 100644 index 1ed6c2deb7..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/ShardsStatsSummary.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * 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. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.snapshot; - -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: snapshot._types.ShardsStatsSummary - -@JsonpDeserializable -public class ShardsStatsSummary implements PlainJsonSerializable { - private final ShardsStatsSummaryItem incremental; - - private final ShardsStatsSummaryItem total; - - private final long startTimeInMillis; - - private final long timeInMillis; - - // --------------------------------------------------------------------------------------------- - - private ShardsStatsSummary(Builder builder) { - - this.incremental = ApiTypeHelper.requireNonNull(builder.incremental, this, "incremental"); - this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - this.startTimeInMillis = ApiTypeHelper.requireNonNull(builder.startTimeInMillis, this, "startTimeInMillis"); - this.timeInMillis = ApiTypeHelper.requireNonNull(builder.timeInMillis, this, "timeInMillis"); - - } - - public static ShardsStatsSummary of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code incremental} - */ - public final ShardsStatsSummaryItem incremental() { - return this.incremental; - } - - /** - * Required - API name: {@code total} - */ - public final ShardsStatsSummaryItem total() { - return this.total; - } - - /** - * Required - API name: {@code start_time_in_millis} - */ - public final long startTimeInMillis() { - return this.startTimeInMillis; - } - - /** - * Required - API name: {@code time_in_millis} - */ - public final long timeInMillis() { - return this.timeInMillis; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("incremental"); - this.incremental.serialize(generator, mapper); - - generator.writeKey("total"); - this.total.serialize(generator, mapper); - - generator.writeKey("start_time_in_millis"); - generator.write(this.startTimeInMillis); - - generator.writeKey("time_in_millis"); - generator.write(this.timeInMillis); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link ShardsStatsSummary}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private ShardsStatsSummaryItem incremental; - - private ShardsStatsSummaryItem total; - - private Long startTimeInMillis; - - private Long timeInMillis; - - /** - * Required - API name: {@code incremental} - */ - public final Builder incremental(ShardsStatsSummaryItem value) { - this.incremental = value; - return this; - } - - /** - * Required - API name: {@code incremental} - */ - public final Builder incremental(Function> fn) { - return this.incremental(fn.apply(new ShardsStatsSummaryItem.Builder()).build()); - } - - /** - * Required - API name: {@code total} - */ - public final Builder total(ShardsStatsSummaryItem value) { - this.total = value; - return this; - } - - /** - * Required - API name: {@code total} - */ - public final Builder total(Function> fn) { - return this.total(fn.apply(new ShardsStatsSummaryItem.Builder()).build()); - } - - /** - * Required - API name: {@code start_time_in_millis} - */ - public final Builder startTimeInMillis(long value) { - this.startTimeInMillis = value; - return this; - } - - /** - * Required - API name: {@code time_in_millis} - */ - public final Builder timeInMillis(long value) { - this.timeInMillis = value; - return this; - } - - /** - * Builds a {@link ShardsStatsSummary}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public ShardsStatsSummary build() { - _checkSingleUse(); - - return new ShardsStatsSummary(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link ShardsStatsSummary} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - ShardsStatsSummary::setupShardsStatsSummaryDeserializer - ); - - protected static void setupShardsStatsSummaryDeserializer(ObjectDeserializer op) { - - op.add(Builder::incremental, ShardsStatsSummaryItem._DESERIALIZER, "incremental"); - op.add(Builder::total, ShardsStatsSummaryItem._DESERIALIZER, "total"); - op.add(Builder::startTimeInMillis, JsonpDeserializer.longDeserializer(), "start_time_in_millis"); - op.add(Builder::timeInMillis, JsonpDeserializer.longDeserializer(), "time_in_millis"); - - } - -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatus.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatus.java deleted file mode 100644 index 21ffa324b4..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotShardsStatus.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.snapshot; - -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: snapshot._types.SnapshotShardsStatus - -@JsonpDeserializable -public class SnapshotShardsStatus implements PlainJsonSerializable { - private final ShardsStatsStage stage; - - private final ShardsStatsSummary stats; - - // --------------------------------------------------------------------------------------------- - - private SnapshotShardsStatus(Builder builder) { - - this.stage = ApiTypeHelper.requireNonNull(builder.stage, this, "stage"); - this.stats = ApiTypeHelper.requireNonNull(builder.stats, this, "stats"); - - } - - public static SnapshotShardsStatus of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code stage} - */ - public final ShardsStatsStage stage() { - return this.stage; - } - - /** - * Required - API name: {@code stats} - */ - public final ShardsStatsSummary stats() { - return this.stats; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("stage"); - this.stage.serialize(generator, mapper); - generator.writeKey("stats"); - this.stats.serialize(generator, mapper); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link SnapshotShardsStatus}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private ShardsStatsStage stage; - - private ShardsStatsSummary stats; - - /** - * Required - API name: {@code stage} - */ - public final Builder stage(ShardsStatsStage value) { - this.stage = value; - return this; - } - - /** - * Required - API name: {@code stats} - */ - public final Builder stats(ShardsStatsSummary value) { - this.stats = value; - return this; - } - - /** - * Required - API name: {@code stats} - */ - public final Builder stats(Function> fn) { - return this.stats(fn.apply(new ShardsStatsSummary.Builder()).build()); - } - - /** - * Builds a {@link SnapshotShardsStatus}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public SnapshotShardsStatus build() { - _checkSingleUse(); - - return new SnapshotShardsStatus(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link SnapshotShardsStatus} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - SnapshotShardsStatus::setupSnapshotShardsStatusDeserializer - ); - - protected static void setupSnapshotShardsStatusDeserializer(ObjectDeserializer op) { - - op.add(Builder::stage, ShardsStatsStage._DESERIALIZER, "stage"); - op.add(Builder::stats, ShardsStatsSummary._DESERIALIZER, "stats"); - - } - -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/get/SnapshotResponseItem.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/get/SnapshotResponseItem.java deleted file mode 100644 index c8e91b9cf6..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/get/SnapshotResponseItem.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.snapshot.get; - -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.opensearch._types.ErrorCause; -import org.opensearch.client.opensearch.snapshot.SnapshotInfo; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: snapshot.get.SnapshotResponseItem - -@JsonpDeserializable -public class SnapshotResponseItem implements PlainJsonSerializable { - private final String repository; - - private final List snapshots; - - @Nullable - private final ErrorCause error; - - // --------------------------------------------------------------------------------------------- - - private SnapshotResponseItem(Builder builder) { - - this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository"); - this.snapshots = ApiTypeHelper.unmodifiable(builder.snapshots); - this.error = builder.error; - - } - - public static SnapshotResponseItem of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code repository} - */ - public final String repository() { - return this.repository; - } - - /** - * API name: {@code snapshots} - */ - public final List snapshots() { - return this.snapshots; - } - - /** - * API name: {@code error} - */ - @Nullable - public final ErrorCause error() { - return this.error; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("repository"); - generator.write(this.repository); - - if (ApiTypeHelper.isDefined(this.snapshots)) { - generator.writeKey("snapshots"); - generator.writeStartArray(); - for (SnapshotInfo item0 : this.snapshots) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - } - if (this.error != null) { - generator.writeKey("error"); - this.error.serialize(generator, mapper); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link SnapshotResponseItem}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String repository; - - @Nullable - private List snapshots; - - @Nullable - private ErrorCause error; - - /** - * Required - API name: {@code repository} - */ - public final Builder repository(String value) { - this.repository = value; - return this; - } - - /** - * API name: {@code snapshots} - *

- * Adds all elements of list to snapshots. - */ - public final Builder snapshots(List list) { - this.snapshots = _listAddAll(this.snapshots, list); - return this; - } - - /** - * API name: {@code snapshots} - *

- * Adds one or more values to snapshots. - */ - public final Builder snapshots(SnapshotInfo value, SnapshotInfo... values) { - this.snapshots = _listAdd(this.snapshots, value, values); - return this; - } - - /** - * API name: {@code snapshots} - *

- * Adds a value to snapshots using a builder lambda. - */ - public final Builder snapshots(Function> fn) { - return snapshots(fn.apply(new SnapshotInfo.Builder()).build()); - } - - /** - * API name: {@code error} - */ - public final Builder error(@Nullable ErrorCause value) { - this.error = value; - return this; - } - - /** - * API name: {@code error} - */ - public final Builder error(Function> fn) { - return this.error(fn.apply(new ErrorCause.Builder()).build()); - } - - /** - * Builds a {@link SnapshotResponseItem}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public SnapshotResponseItem build() { - _checkSingleUse(); - - return new SnapshotResponseItem(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link SnapshotResponseItem} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - SnapshotResponseItem::setupSnapshotResponseItemDeserializer - ); - - protected static void setupSnapshotResponseItemDeserializer(ObjectDeserializer op) { - - op.add(Builder::repository, JsonpDeserializer.stringDeserializer(), "repository"); - op.add(Builder::snapshots, JsonpDeserializer.arrayDeserializer(SnapshotInfo._DESERIALIZER), "snapshots"); - op.add(Builder::error, ErrorCause._DESERIALIZER, "error"); - - } - -} diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index f21d3aa555..27ce083408 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -15206,63 +15206,63 @@ components: cat.aliases___query.expand_wildcards: in: query name: expand_wildcards - description: Whether to expand wildcard expression to concrete indexes that are open, closed or both. + description: Expands wildcard expressions to concrete indexes. Combine multiple values with commas. Supported values are `all`, `open`, `closed`, `hidden`, and `none`. schema: $ref: '#/components/schemas/_common___ExpandWildcards' style: form cat.aliases___query.format: name: format in: query - description: A short version of the Accept header (for example, `json`, `yaml`). + description: A short version of the `Accept` header, such as `json` or `yaml`. schema: type: string - description: A short version of the Accept header (for example, `json`, `yaml`). + description: A short version of the `Accept` header, such as `json` or `yaml`. cat.aliases___query.h: name: h in: query - description: Comma-separated list of column names to display. + description: A comma-separated list of column names to display. style: form schema: type: array items: type: string - description: Comma-separated list of column names to display. + description: A comma-separated list of column names to display. explode: true cat.aliases___query.help: name: help in: query - description: Return help information. + description: Returns help information. schema: - description: Return help information. + description: Returns help information. type: boolean default: false cat.aliases___query.local: name: local in: query - description: Return local information, do not retrieve the state from cluster-manager node. + description: Whether to return information from the local node only instead of from the cluster manager node. schema: type: boolean default: false - description: Return local information, do not retrieve the state from cluster-manager node. + description: Whether to return information from the local node only instead of from the cluster manager node. cat.aliases___query.s: name: s in: query - description: Comma-separated list of column names or column aliases to sort by. + description: A comma-separated list of column names or column aliases to sort by. style: form schema: type: array items: type: string - description: Comma-separated list of column names or column aliases to sort by. + description: A comma-separated list of column names or column aliases to sort by. explode: true cat.aliases___query.v: name: v in: query - description: Verbose mode. Display column headers. + description: Enables verbose mode, which displays column headers. schema: type: boolean default: false - description: Verbose mode. Display column headers. + description: Enables verbose mode, which displays column headers. cat.all_pit_segments___query.bytes: name: bytes in: query @@ -15317,7 +15317,7 @@ components: cat.allocation___path.node_id: in: path name: node_id - description: Comma-separated list of node identifiers or names used to limit the returned information. + description: A comma-separated list of node IDs or names used to limit the returned information. required: true schema: $ref: '#/components/schemas/_common___NodeIds' @@ -15325,55 +15325,55 @@ components: cat.allocation___query.bytes: in: query name: bytes - description: The unit used to display byte values. + description: The units used to display byte values. schema: $ref: '#/components/schemas/_common___ByteUnit' style: form cat.allocation___query.cluster_manager_timeout: name: cluster_manager_timeout in: query - description: Operation timeout for connection to cluster-manager node. + description: A timeout for connection to the cluster manager node. schema: $ref: '#/components/schemas/_common___Duration' x-version-added: '2.0' cat.allocation___query.format: name: format in: query - description: A short version of the Accept header (for example, `json`, `yaml`). + description: A short version of the HTTP `Accept` header, such as `json` or `yaml`. schema: type: string - description: A short version of the Accept header (for example, `json`, `yaml`). + description: A short version of the HTTP `Accept` header, such as `json` or `yaml`. cat.allocation___query.h: name: h in: query - description: Comma-separated list of column names to display. + description: A comma-separated list of column names to display. style: form schema: type: array items: type: string - description: Comma-separated list of column names to display. + description: A comma-separated list of column names to display. explode: true cat.allocation___query.help: name: help in: query - description: Return help information. + description: Returns help information. schema: type: boolean default: false - description: Return help information. + description: Returns help information. cat.allocation___query.local: name: local in: query - description: Return local information, do not retrieve the state from cluster-manager node. + description: Returns local information but does not retrieve the state from cluster-manager node. schema: type: boolean default: false - description: Return local information, do not retrieve the state from cluster-manager node. + description: Returns local information but does not retrieve the state from cluster-manager node. cat.allocation___query.master_timeout: name: master_timeout in: query - description: Operation timeout for connection to cluster-manager node. + description: A timeout for connection to the cluster manager node. schema: $ref: '#/components/schemas/_common___Duration' x-version-deprecated: '2.0' @@ -15382,46 +15382,46 @@ components: cat.allocation___query.s: name: s in: query - description: Comma-separated list of column names or column aliases to sort by. + description: A comma-separated list of column names or column aliases to sort by. style: form schema: type: array items: type: string - description: Comma-separated list of column names or column aliases to sort by. + description: A comma-separated list of column names or column aliases to sort by. explode: true cat.allocation___query.v: name: v in: query - description: Verbose mode. Display column headers. + description: Enables verbose mode, which displays column headers. schema: type: boolean default: false - description: Verbose mode. Display column headers. + description: Enables verbose mode, which displays column headers. cat.cluster_manager___query.cluster_manager_timeout: name: cluster_manager_timeout in: query - description: Operation timeout for connection to cluster-manager node. + description: A timeout for connection to the cluster manager node. schema: $ref: '#/components/schemas/_common___Duration' x-version-added: '2.0' cat.cluster_manager___query.format: name: format in: query - description: A short version of the Accept header (for example, `json`, `yaml`). + description: A short version of the HTTP `Accept` header, such as `json` or `yaml`. schema: type: string - description: A short version of the Accept header (for example, `json`, `yaml`). + description: A short version of the HTTP `Accept` header, such as `json` or `yaml`. cat.cluster_manager___query.h: name: h in: query - description: Comma-separated list of column names to display. + description: A comma-separated list of column names to display. style: form schema: type: array items: type: string - description: Comma-separated list of column names to display. + description: A comma-separated list of column names to display. explode: true cat.cluster_manager___query.help: name: help @@ -15442,7 +15442,7 @@ components: cat.cluster_manager___query.master_timeout: name: master_timeout in: query - description: Operation timeout for connection to cluster-manager node. + description: A timeout for connection to the cluster manager node. schema: $ref: '#/components/schemas/_common___Duration' x-version-deprecated: '2.0' @@ -15451,22 +15451,22 @@ components: cat.cluster_manager___query.s: name: s in: query - description: Comma-separated list of column names or column aliases to sort by. + description: A comma-separated list of column names or column aliases to sort by. style: form schema: type: array items: type: string - description: Comma-separated list of column names or column aliases to sort by. + description: A comma-separated list of column names or column aliases to sort by. explode: true cat.cluster_manager___query.v: name: v in: query - description: Verbose mode. Display column headers. + description: Enables verbose mode, which displays column headers. schema: type: boolean default: false - description: Verbose mode. Display column headers. + description: Enables verbose mode, which displays column headers. cat.count___path.index: in: path name: index @@ -27374,16 +27374,15 @@ components: schema: type: object properties: - file: - type: string + id: + $ref: '#/components/schemas/_common___Id' params: description: |- Key-value pairs used to replace Mustache variables in the template. The key is the variable name. The value is the variable value. type: object - additionalProperties: - type: object + additionalProperties: true source: description: |- An inline search template. @@ -31852,7 +31851,7 @@ components: snapshots: type: array items: - $ref: '#/components/schemas/snapshot._common___Status' + $ref: '#/components/schemas/snapshot._common___SnapshotStatus' required: - snapshots description: '' @@ -53466,7 +53465,7 @@ components: type: boolean model_index_status: oneOf: - - $ref: '#/components/schemas/_common___HealthStatusCapitalized' + - $ref: '#/components/schemas/_common___HealthStatus' - type: 'null' nodes: type: object @@ -58596,7 +58595,8 @@ components: type: object properties: file_count: - type: number + type: integer + format: int32 size_in_bytes: $ref: '#/components/schemas/_common___ByteCount' required: @@ -58620,79 +58620,15 @@ 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: - type: object - properties: - done: - type: number - failed: - type: number - finalizing: - type: number - initializing: - type: number - started: - type: number - total: - type: number - required: - - done - - failed - - finalizing - - initializing - - started - - total - snapshot._common___ShardsStatsStage: - type: string - enum: - - DONE - - FAILURE - - FINALIZE - - INIT - - STARTED - snapshot._common___ShardsStatsSummary: - type: object - properties: - incremental: - $ref: '#/components/schemas/snapshot._common___ShardsStatsSummaryItem' - total: - $ref: '#/components/schemas/snapshot._common___ShardsStatsSummaryItem' - start_time_in_millis: - $ref: '#/components/schemas/_common___EpochTimeUnitMillis' - time: - $ref: '#/components/schemas/_common___Duration' - time_in_millis: - $ref: '#/components/schemas/_common___DurationValueUnitMillis' - required: - - incremental - - start_time_in_millis - - time_in_millis - - total - snapshot._common___ShardsStatsSummaryItem: - type: object - properties: - file_count: - type: number - size_in_bytes: - $ref: '#/components/schemas/_common___ByteCount' - required: - - file_count - - size_in_bytes snapshot._common___SnapshotIndexStats: type: object properties: @@ -58701,7 +58637,7 @@ components: additionalProperties: $ref: '#/components/schemas/snapshot._common___SnapshotShardsStatus' shards_stats: - $ref: '#/components/schemas/snapshot._common___ShardsStats' + $ref: '#/components/schemas/snapshot._common___SnapshotShardsStats' stats: $ref: '#/components/schemas/snapshot._common___SnapshotStats' required: @@ -58779,13 +58715,93 @@ components: - reason - shard_id - status + snapshot._common___SnapshotShardsStats: + type: object + properties: + done: + type: integer + format: int64 + failed: + type: integer + format: int64 + finalizing: + type: integer + format: int64 + initializing: + type: integer + format: int64 + started: + type: integer + format: int64 + total: + type: integer + format: int64 + required: + - done + - failed + - finalizing + - initializing + - started + - total + snapshot._common___SnapshotShardsStatsStage: + oneOf: + - type: string + const: DONE + description: Number of shards in the snapshot that were successfully stored in the repository. + - type: string + const: FAILURE + description: Number of shards in the snapshot that were not successfully stored in the repository. + - type: string + const: FINALIZE + description: Number of shards in the snapshot that are in the finalizing stage of being stored in the repository. + - type: string + const: INIT + description: Number of shards in the snapshot that are in the initializing stage of being stored in the repository. + - type: string + const: STARTED + description: Number of shards in the snapshot that are in the started stage of being stored in the repository. + snapshot._common___SnapshotShardsStatsSummary: + type: object + properties: + incremental: + $ref: '#/components/schemas/snapshot._common___SnapshotShardsStatsSummaryItem' + processed: + $ref: '#/components/schemas/snapshot._common___SnapshotShardsStatsSummaryItem' + total: + $ref: '#/components/schemas/snapshot._common___SnapshotShardsStatsSummaryItem' + start_time_in_millis: + $ref: '#/components/schemas/_common___EpochTimeUnitMillis' + time: + $ref: '#/components/schemas/_common___Duration' + time_in_millis: + $ref: '#/components/schemas/_common___DurationValueUnitMillis' + required: + - incremental + - start_time_in_millis + - time_in_millis + - total + snapshot._common___SnapshotShardsStatsSummaryItem: + type: object + properties: + file_count: + type: integer + format: int64 + size_in_bytes: + $ref: '#/components/schemas/_common___ByteCount' + required: + - file_count + - size_in_bytes snapshot._common___SnapshotShardsStatus: type: object properties: + node: + $ref: '#/components/schemas/_common___NodeId' + reason: + type: string stage: - $ref: '#/components/schemas/snapshot._common___ShardsStatsStage' + $ref: '#/components/schemas/snapshot._common___SnapshotShardsStatsStage' stats: - $ref: '#/components/schemas/snapshot._common___ShardsStatsSummary' + $ref: '#/components/schemas/snapshot._common___SnapshotShardsStatsSummary' required: - stage - stats @@ -58794,6 +58810,8 @@ components: properties: incremental: $ref: '#/components/schemas/snapshot._common___FileCountSnapshotStats' + processed: + $ref: '#/components/schemas/snapshot._common___FileCountSnapshotStats' start_time_in_millis: $ref: '#/components/schemas/_common___EpochTimeUnitMillis' time: @@ -58807,7 +58825,7 @@ components: - start_time_in_millis - time_in_millis - total - snapshot._common___Status: + snapshot._common___SnapshotStatus: type: object properties: include_global_state: @@ -58819,7 +58837,7 @@ components: repository: type: string shards_stats: - $ref: '#/components/schemas/snapshot._common___ShardsStats' + $ref: '#/components/schemas/snapshot._common___SnapshotShardsStats' snapshot: type: string state: @@ -58829,7 +58847,6 @@ components: uuid: $ref: '#/components/schemas/_common___Uuid' required: - - include_global_state - indices - repository - shards_stats 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..b1d377ea34 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,8 +68,8 @@ public class CodeGenerator { isNot("search_models") ) ), - and(namespace(is("snapshot")), name(isOneOf("cleanup_repository", "clone", "create", "get", "verify_repository"))), - and(namespace(is("tasks"))) + namespace(is("snapshot")), + namespace(is("tasks")) ); public static void main(String[] args) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java index 1416a707d4..1e2d186b5a 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java @@ -24,7 +24,7 @@ import org.opensearch.client.codegen.utils.Strings; public class Namespace { - private static final Set PARTIAL_NAMESPACES = Set.of("", "snapshot", "indices"); + private static final Set PARTIAL_NAMESPACES = Set.of("", "indices"); private final Namespace parent; private final String name; 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..f8c39d37cd 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(); } @@ -233,8 +240,14 @@ private static String classBaseName(@Nonnull OperationGroup operationGroup) { return "CloneSnapshot"; case "snapshot.create": return "CreateSnapshot"; + case "snapshot.delete": + return "DeleteSnapshot"; case "snapshot.get": return "GetSnapshot"; + case "snapshot.restore": + return "RestoreSnapshot"; + case "snapshot.status": + return "SnapshotStatus"; case "tasks.get": return "GetTasks"; default: 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(); + } + } +}