diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a2faa175a..c8910abcfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ This section is for maintaining a changelog for all breaking changes for the cli - Fixed an issue where `FieldSort` was not implementing `SortOptionsVariant` ([#1323](https://github.com/opensearch-project/opensearch-java/pull/1323)) - Fixed don't invoke the mapper's serialize method for the RangeQuery JsonData raw value ([#1309](https://github.com/opensearch-project/opensearch-java/pull/1309)) - Fixed `GetSnapshotResponse` deserialization ([#1299](https://github.com/opensearch-project/opensearch-java/pull/1299)) +- Fixed `CreateSnapshotResponse` deserialization when wait_for_completion is false ([#1332](https://github.com/opensearch-project/opensearch-java/pull/1332)) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java similarity index 62% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java index 4a1e14baea..6f9694f9ad 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java @@ -30,13 +30,20 @@ * 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.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -51,17 +58,27 @@ 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.Request /** * Creates a snapshot in a repository. - * */ @JsonpDeserializable -public class CreateSnapshotRequest extends RequestBase implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class CreateSnapshotRequest extends RequestBase + implements + PlainJsonSerializable, + ToCopyableBuilder { + + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final List featureStates; @Nullable @@ -70,22 +87,23 @@ public class CreateSnapshotRequest extends RequestBase implements PlainJsonSeria @Nullable private final Boolean includeGlobalState; + @Nonnull private final List indices; @Deprecated @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - + @Nonnull private final Map metadata; @Nullable private final Boolean partial; + @Nonnull private final String repository; + @Nonnull private final String snapshot; @Nullable @@ -94,46 +112,54 @@ public class CreateSnapshotRequest extends RequestBase implements PlainJsonSeria // --------------------------------------------------------------------------------------------- private CreateSnapshotRequest(Builder builder) { - + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.featureStates = ApiTypeHelper.unmodifiable(builder.featureStates); this.ignoreUnavailable = builder.ignoreUnavailable; this.includeGlobalState = builder.includeGlobalState; this.indices = ApiTypeHelper.unmodifiable(builder.indices); this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); this.partial = builder.partial; this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository"); this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); this.waitForCompletion = builder.waitForCompletion; - } - public static CreateSnapshotRequest of(Function> fn) { + public static CreateSnapshotRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Feature states to include in the snapshot. Each feature state includes one or - * more system indices containing related data. You can view a list of eligible - * features using the get features API. If include_global_state is - * true, all current feature states are included by default. If - * include_global_state is false, no feature states - * are included by default. + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * Feature states to include in the snapshot. Each feature state includes one or more system indexes containing related data. You can + * view a list of eligible features using the get features API. If include_global_state is true, all current + * feature states are included by default. If include_global_state is false, no feature states are included by + * default. *

* API name: {@code feature_states} + *

*/ + @Nonnull public final List featureStates() { return this.featureStates; } /** - * If true, the request ignores data streams and indices in - * indices 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 indices that are missing or closed. If + * false, the request returns an error for any data stream or index that is missing or closed. *

* API name: {@code ignore_unavailable} + *

*/ @Nullable public final Boolean ignoreUnavailable() { @@ -141,13 +167,12 @@ public final Boolean ignoreUnavailable() { } /** - * If true, the current cluster state is included in the snapshot. - * The cluster state includes persistent cluster settings, composable index - * templates, legacy index templates, ingest pipelines, and ILM policies. It - * also includes data stored in system indices, such as Watches and task records - * (configurable via feature_states). + * If true, the current cluster state is included in the snapshot. The cluster state includes persistent cluster settings, + * composable index templates, legacy index templates, ingest pipelines, and ILM policies. It also includes data stored in system + * indexes, such as Watches and task records (configurable with feature_states). *

* API name: {@code include_global_state} + *

*/ @Nullable public final Boolean includeGlobalState() { @@ -155,20 +180,19 @@ public final Boolean includeGlobalState() { } /** - * Data streams and indices to include in the snapshot. Supports multi-target - * syntax. Includes all data streams and indices by default. - *

* API name: {@code indices} */ + @Nonnull public final List indices() { return this.indices; } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails + * and returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated @Nullable @@ -177,34 +201,20 @@ public final Time masterTimeout() { } /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} - */ - @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - /** - * Optional metadata for the snapshot. May have any contents. Must be less than - * 1024 bytes. This map is not automatically generated by OpenSearch. - *

* API name: {@code metadata} */ + @Nonnull public final Map metadata() { return this.metadata; } /** - * If true, allows restoring a partial snapshot of indices with - * unavailable shards. Only shards that were successfully included in the - * snapshot will be restored. All missing shards will be recreated as empty. If - * false, the entire restore operation will fail if one or more - * indices included in the snapshot do not have all primary shards available. + * If true, allows restoring a partial snapshot of indexes with unavailable shards. Only shards that were successfully + * included in the snapshot will be restored. All missing shards will be recreated as empty. If false, the entire restore + * operation will fail if one or more indexes included in the snapshot do not have all primary shards available. *

* API name: {@code partial} + *

*/ @Nullable public final Boolean partial() { @@ -215,7 +225,9 @@ public final Boolean partial() { * Required - Repository for the snapshot. *

* API name: {@code repository} + *

*/ + @Nonnull public final String repository() { return this.repository; } @@ -224,17 +236,19 @@ public final String repository() { * Required - Name of the snapshot. Must be unique in the repository. *

* API name: {@code snapshot} + *

*/ + @Nonnull public final String snapshot() { return this.snapshot; } /** - * If true, the request returns a response when the snapshot is - * complete. If false, the request returns a response when the - * snapshot initializes. + * If true, the request returns a response when the snapshot is complete. If false, the request returns a + * response when the snapshot initializes. *

* API name: {@code wait_for_completion} + *

*/ @Nullable public final Boolean waitForCompletion() { @@ -244,6 +258,7 @@ public final Boolean waitForCompletion() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -251,261 +266,299 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.featureStates)) { generator.writeKey("feature_states"); generator.writeStartArray(); for (String item0 : this.featureStates) { generator.write(item0); - } generator.writeEnd(); - } + if (this.ignoreUnavailable != null) { generator.writeKey("ignore_unavailable"); generator.write(this.ignoreUnavailable); - } + if (this.includeGlobalState != null) { generator.writeKey("include_global_state"); generator.write(this.includeGlobalState); - } + if (ApiTypeHelper.isDefined(this.indices)) { generator.writeKey("indices"); generator.writeStartArray(); for (String item0 : this.indices) { generator.write(item0); - } generator.writeEnd(); - } + if (ApiTypeHelper.isDefined(this.metadata)) { generator.writeKey("metadata"); generator.writeStartObject(); for (Map.Entry item0 : this.metadata.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.partial != null) { generator.writeKey("partial"); generator.write(this.partial); - } + } + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link CreateSnapshotRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private Time clusterManagerTimeout; @Nullable private List featureStates; - @Nullable private Boolean ignoreUnavailable; - @Nullable private Boolean includeGlobalState; - @Nullable private List indices; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - @Nullable private Map metadata; - @Nullable private Boolean partial; - private String repository; - private String snapshot; - @Nullable private Boolean waitForCompletion; + public Builder() {} + + private Builder(CreateSnapshotRequest o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.featureStates = _listCopy(o.featureStates); + this.ignoreUnavailable = o.ignoreUnavailable; + this.includeGlobalState = o.includeGlobalState; + this.indices = _listCopy(o.indices); + this.masterTimeout = o.masterTimeout; + this.metadata = _mapCopy(o.metadata); + this.partial = o.partial; + this.repository = o.repository; + this.snapshot = o.snapshot; + this.waitForCompletion = o.waitForCompletion; + } + + private Builder(Builder o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.featureStates = _listCopy(o.featureStates); + this.ignoreUnavailable = o.ignoreUnavailable; + this.includeGlobalState = o.includeGlobalState; + this.indices = _listCopy(o.indices); + this.masterTimeout = o.masterTimeout; + this.metadata = _mapCopy(o.metadata); + this.partial = o.partial; + this.repository = o.repository; + this.snapshot = o.snapshot; + 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()); + } + /** - * Feature states to include in the snapshot. Each feature state includes one or - * more system indices containing related data. You can view a list of eligible - * features using the get features API. If include_global_state is - * true, all current feature states are included by default. If - * include_global_state is false, no feature states - * are included by default. + * Feature states to include in the snapshot. Each feature state includes one or more system indexes containing related data. You + * can view a list of eligible features using the get features API. If include_global_state is true, all + * current feature states are included by default. If include_global_state is false, no feature states are + * included by default. *

* API name: {@code feature_states} + *

+ * *

* Adds all elements of list to featureStates. + *

*/ + @Nonnull public final Builder featureStates(List list) { this.featureStates = _listAddAll(this.featureStates, list); return this; } /** - * Feature states to include in the snapshot. Each feature state includes one or - * more system indices containing related data. You can view a list of eligible - * features using the get features API. If include_global_state is - * true, all current feature states are included by default. If - * include_global_state is false, no feature states - * are included by default. + * Feature states to include in the snapshot. Each feature state includes one or more system indexes containing related data. You + * can view a list of eligible features using the get features API. If include_global_state is true, all + * current feature states are included by default. If include_global_state is false, no feature states are + * included by default. *

* API name: {@code feature_states} + *

+ * *

* Adds one or more values to featureStates. + *

*/ + @Nonnull public final Builder featureStates(String value, String... values) { this.featureStates = _listAdd(this.featureStates, value, values); return this; } /** - * If true, the request ignores data streams and indices in - * indices 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 indices that are missing or closed. If + * false, the request returns an error for any data stream or index that is missing or closed. *

* API name: {@code ignore_unavailable} + *

*/ + @Nonnull public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** - * If true, the current cluster state is included in the snapshot. - * The cluster state includes persistent cluster settings, composable index - * templates, legacy index templates, ingest pipelines, and ILM policies. It - * also includes data stored in system indices, such as Watches and task records - * (configurable via feature_states). + * If true, the current cluster state is included in the snapshot. The cluster state includes persistent cluster + * settings, composable index templates, legacy index templates, ingest pipelines, and ILM policies. It also includes data stored in + * system indexes, such as Watches and task records (configurable with feature_states). *

* API name: {@code include_global_state} + *

*/ + @Nonnull public final Builder includeGlobalState(@Nullable Boolean value) { this.includeGlobalState = value; return this; } /** - * Data streams and indices to include in the snapshot. Supports multi-target - * syntax. Includes all data streams and indices by default. - *

* 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; } /** - * Data streams and indices to include in the snapshot. Supports multi-target - * syntax. Includes all data streams and indices by default. - *

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

* API name: {@code master_timeout} + *

*/ @Deprecated + @Nonnull public final Builder masterTimeout(@Nullable Time value) { this.masterTimeout = value; return this; } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request + * fails and returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated + @Nonnull public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; - return this; - } - - /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** - * Optional metadata for the snapshot. May have any contents. Must be less than - * 1024 bytes. This map is not automatically generated by OpenSearch. - *

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

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

*/ + @Nonnull public final Builder metadata(Map map) { this.metadata = _mapPutAll(this.metadata, map); return this; } /** - * Optional metadata for the snapshot. May have any contents. Must be less than - * 1024 bytes. This map is not automatically generated by OpenSearch. - *

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

* Adds an entry to metadata. + *

*/ + @Nonnull public final Builder metadata(String key, JsonData value) { this.metadata = _mapPut(this.metadata, key, value); return this; } /** - * If true, allows restoring a partial snapshot of indices with - * unavailable shards. Only shards that were successfully included in the - * snapshot will be restored. All missing shards will be recreated as empty. If - * false, the entire restore operation will fail if one or more - * indices included in the snapshot do not have all primary shards available. + * If true, allows restoring a partial snapshot of indexes with unavailable shards. Only shards that were successfully + * included in the snapshot will be restored. All missing shards will be recreated as empty. If false, the entire + * restore operation will fail if one or more indexes included in the snapshot do not have all primary shards available. *

* API name: {@code partial} + *

*/ + @Nonnull public final Builder partial(@Nullable Boolean value) { this.partial = value; return this; @@ -515,7 +568,9 @@ public final Builder partial(@Nullable Boolean value) { * Required - Repository for the snapshot. *

* API name: {@code repository} + *

*/ + @Nonnull public final Builder repository(String value) { this.repository = value; return this; @@ -525,19 +580,22 @@ public final Builder repository(String value) { * Required - Name of the snapshot. Must be unique in the repository. *

* API name: {@code snapshot} + *

*/ + @Nonnull public final Builder snapshot(String value) { this.snapshot = value; return this; } /** - * If true, the request returns a response when the snapshot is - * complete. If false, the request returns a response when the - * snapshot initializes. + * If true, the request returns a response when the snapshot is complete. If false, the request returns a + * response when the snapshot initializes. *

* API name: {@code wait_for_completion} + *

*/ + @Nonnull public final Builder waitForCompletion(@Nullable Boolean value) { this.waitForCompletion = value; return this; @@ -546,9 +604,10 @@ public final Builder waitForCompletion(@Nullable Boolean value) { /** * Builds a {@link CreateSnapshotRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public CreateSnapshotRequest build() { _checkSingleUse(); @@ -567,14 +626,14 @@ public CreateSnapshotRequest build() { ); protected static void setupCreateSnapshotRequestDeserializer(ObjectDeserializer op) { - op.add(Builder::featureStates, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "feature_states"); op.add(Builder::ignoreUnavailable, JsonpDeserializer.booleanDeserializer(), "ignore_unavailable"); op.add(Builder::includeGlobalState, JsonpDeserializer.booleanDeserializer(), "include_global_state"); op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); op.add(Builder::metadata, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "metadata"); op.add(Builder::partial, JsonpDeserializer.booleanDeserializer(), "partial"); - + op.add(Builder::repository, JsonpDeserializer.stringDeserializer(), "repository"); + op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); } // --------------------------------------------------------------------------------------------- @@ -583,53 +642,68 @@ protected static void setupCreateSnapshotRequestDeserializer(ObjectDeserializer< * Endpoint "{@code snapshot.create}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "PUT"; - - }, - + request -> "PUT", // 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()); + } if (request.waitForCompletion != null) { params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); } return params; - }, SimpleEndpoint.emptyMap(), true, CreateSnapshotResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.featureStates); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.includeGlobalState); + result = 31 * result + Objects.hashCode(this.indices); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + Objects.hashCode(this.metadata); + result = 31 * result + Objects.hashCode(this.partial); + result = 31 * result + this.repository.hashCode(); + result = 31 * result + this.snapshot.hashCode(); + 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; + CreateSnapshotRequest other = (CreateSnapshotRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.featureStates, other.featureStates) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.includeGlobalState, other.includeGlobalState) + && Objects.equals(this.indices, other.indices) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.metadata, other.metadata) + && Objects.equals(this.partial, other.partial) + && this.repository.equals(other.repository) + && this.snapshot.equals(other.snapshot) + && Objects.equals(this.waitForCompletion, other.waitForCompletion); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotResponse.java similarity index 60% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotResponse.java index 301bda1d05..a64a5cd930 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotResponse.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; @@ -41,34 +48,43 @@ 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.create.Response @JsonpDeserializable -public class CreateSnapshotResponse implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class CreateSnapshotResponse + implements + PlainJsonSerializable, + ToCopyableBuilder { + @Nullable private final Boolean accepted; + @Nullable private final SnapshotInfo snapshot; // --------------------------------------------------------------------------------------------- private CreateSnapshotResponse(Builder builder) { - this.accepted = builder.accepted; - this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); - + this.snapshot = builder.snapshot; } - public static CreateSnapshotResponse of(Function> fn) { + public static CreateSnapshotResponse of(Function> fn) { return fn.apply(new Builder()).build(); } /** + * Returns true if the snapshot was accepted. Present when the request had wait_for_completion set to + * false. + *

* API name: {@code accepted} + *

*/ @Nullable public final Boolean accepted() { @@ -76,8 +92,9 @@ public final Boolean accepted() { } /** - * Required - API name: {@code snapshot} + * API name: {@code snapshot} */ + @Nullable public final SnapshotInfo snapshot() { return this.snapshot; } @@ -85,6 +102,7 @@ public final SnapshotInfo snapshot() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -92,58 +110,94 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.accepted != null) { generator.writeKey("accepted"); generator.write(this.accepted); - } - generator.writeKey("snapshot"); - this.snapshot.serialize(generator, mapper); + 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 CreateSnapshotResponse}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private Boolean accepted; - + @Nullable private SnapshotInfo snapshot; + public Builder() {} + + private Builder(CreateSnapshotResponse 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 snapshot 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; } /** - * Required - API name: {@code snapshot} + * API name: {@code snapshot} */ - public final Builder snapshot(SnapshotInfo value) { + @Nonnull + public final Builder snapshot(@Nullable SnapshotInfo value) { this.snapshot = value; return this; } /** - * Required - API name: {@code snapshot} + * API name: {@code snapshot} */ + @Nonnull public final Builder snapshot(Function> fn) { - return this.snapshot(fn.apply(new SnapshotInfo.Builder()).build()); + return snapshot(fn.apply(new SnapshotInfo.Builder()).build()); } /** * Builds a {@link CreateSnapshotResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public CreateSnapshotResponse build() { _checkSingleUse(); @@ -162,10 +216,23 @@ public CreateSnapshotResponse build() { ); protected static void setupCreateSnapshotResponseDeserializer(ObjectDeserializer op) { - op.add(Builder::accepted, JsonpDeserializer.booleanDeserializer(), "accepted"); op.add(Builder::snapshot, SnapshotInfo._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; + CreateSnapshotResponse other = (CreateSnapshotResponse) o; + return Objects.equals(this.accepted, other.accepted) && Objects.equals(this.snapshot, other.snapshot); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java index ce3ca27aca..615f8a5882 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java @@ -99,6 +99,26 @@ public final CompletableFuture clone( return clone(fn.apply(new CloneSnapshotRequest.Builder()).build()); } + // ----- Endpoint: snapshot.create + + /** + * Creates a snapshot in a repository. + */ + public CompletableFuture create(CreateSnapshotRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, CreateSnapshotRequest._ENDPOINT, this.transportOptions); + } + + /** + * Creates a snapshot in a repository. + * + * @param fn a function that initializes a builder to create the {@link CreateSnapshotRequest} + */ + public final CompletableFuture create( + Function> fn + ) throws IOException, OpenSearchException { + return create(fn.apply(new CreateSnapshotRequest.Builder()).build()); + } + // ----- Endpoint: snapshot.get /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java index 50ca8e3870..84844ee8cb 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java @@ -96,6 +96,25 @@ public final CloneSnapshotResponse clone(Function> fn) + throws IOException, OpenSearchException { + return create(fn.apply(new CreateSnapshotRequest.Builder()).build()); + } + // ----- Endpoint: snapshot.get /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java index 305d795e6b..86e3016d6b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClient.java @@ -79,21 +79,6 @@ public CompletableFuture create(CreateSnapshotRequest re return this.transport.performRequestAsync(request, endpoint, this.transportOptions); } - /** - * Creates a snapshot in a repository. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateSnapshotRequest} - * - */ - - public final CompletableFuture create( - Function> fn - ) throws IOException, OpenSearchException { - return create(fn.apply(new CreateSnapshotRequest.Builder()).build()); - } - // ----- Endpoint: snapshot.create_repository /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java index 1491697e93..e80cf77ee8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClient.java @@ -78,20 +78,6 @@ public CreateSnapshotResponse create(CreateSnapshotRequest request) throws IOExc return this.transport.performRequest(request, endpoint, this.transportOptions); } - /** - * Creates a snapshot in a repository. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateSnapshotRequest} - * - */ - - public final CreateSnapshotResponse create(Function> fn) - throws IOException, OpenSearchException { - return create(fn.apply(new CreateSnapshotRequest.Builder()).build()); - } - // ----- Endpoint: snapshot.create_repository /** 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 84efd20cdf..d1c171e4c6 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 @@ -58,7 +58,7 @@ public class CodeGenerator { ) ), and(namespace("ml"), not(named("search_models"))), // TODO: search_models is complex and ideally should re-use the search structures - and(namespace("snapshot"), named("cleanup_repository", "clone", "get", "verify_repository")), + and(namespace("snapshot"), named("cleanup_repository", "clone", "create", "get", "verify_repository")), and(namespace("tasks")) ); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index fe492f1dbe..2598142e72 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 @@ -202,6 +202,8 @@ private static String classBaseName(@Nonnull OperationGroup operationGroup) { return "GetIndex"; case "snapshot.clone": return "CloneSnapshot"; + case "snapshot.create": + return "CreateSnapshot"; case "snapshot.get": return "GetSnapshot"; case "tasks.get":