diff --git a/CHANGELOG.md b/CHANGELOG.md index 046a471cee..ed04fffcb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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 an issue where `FieldSort` was not implementing `SortOptionsVariant` ([#1323](https://github.com/opensearch-project/opensearch-java/pull/1323)) - Fixed `CreateSnapshotResponse` deserialization when wait_for_completion is false ([#1332](https://github.com/opensearch-project/opensearch-java/pull/1332)) +- Fixed `GetSnapshotResponse` deserialization ([#1299](https://github.com/opensearch-project/opensearch-java/pull/1299)) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.java index 79fa89d264..dd2ebe24f4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.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; @@ -51,9 +57,8 @@ /** * Returns information about a snapshot. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetSnapshotRequest extends RequestBase { @Nullable private final Boolean human; @@ -61,9 +66,11 @@ public class GetSnapshotRequest extends RequestBase { @Nullable private final Boolean ignoreUnavailable; + @Deprecated @Nullable private final Boolean includeRepository; + @Deprecated @Nullable private final Boolean indexDetails; @@ -74,8 +81,10 @@ public class GetSnapshotRequest extends RequestBase { @Nullable private final Time clusterManagerTimeout; + @Nonnull private final String repository; + @Nonnull private final List snapshot; @Nullable @@ -84,8 +93,8 @@ public class GetSnapshotRequest extends RequestBase { // --------------------------------------------------------------------------------------------- private GetSnapshotRequest(Builder builder) { - this.human = builder.human; + this.ignoreUnavailable = builder.ignoreUnavailable; this.includeRepository = builder.includeRepository; this.indexDetails = builder.indexDetails; @@ -97,23 +106,26 @@ private GetSnapshotRequest(Builder builder) { } - public static GetSnapshotRequest of(Function> fn) { + public static GetSnapshotRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * API name: {@code human} + * Operation timeout for connection to cluster-manager node. + *

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

*/ @Nullable - public final Boolean human() { - return this.human; + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; } /** - * If false, the request returns an error for any snapshots that are - * unavailable. + * If false, the request returns an error for any snapshots that are unavailable. *

* API name: {@code ignore_unavailable} + *

*/ @Nullable public final Boolean ignoreUnavailable() { @@ -121,34 +133,29 @@ public final Boolean ignoreUnavailable() { } /** - * Whether to include the repository name in the snapshot info. Defaults to - * true. - *

- * API name: {@code include_repository} + * This method is left for compatibility. */ @Nullable + @Deprecated public final Boolean includeRepository() { return this.includeRepository; } /** - * If true, returns additional information about each index in the snapshot - * comprising the number of shards in the index, the total size of the index in - * bytes, and the maximum number of segments per shard in the index. Defaults to - * false, meaning that this information is omitted. - *

- * API name: {@code index_details} + * * This method is left for compatibility. */ @Nullable + @Deprecated public final Boolean indexDetails() { return this.indexDetails; } /** - * 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 @@ -157,48 +164,40 @@ 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; - } - - /** - * Required - Comma-separated list of snapshot repository names used to limit - * the request. Wildcard (*) expressions are supported. + * Required - Comma-separated list of snapshot repository names used to limit the request. Wildcard (*) expressions are supported. *

* API name: {@code repository} + *

*/ + @Nonnull public final String repository() { return this.repository; } /** - * Required - Comma-separated list of snapshot names to retrieve. Also accepts - * wildcards (*). + * Required - + *

+ * Comma-separated list of snapshot names to retrieve. Also accepts wildcards (*). + *

*
    - *
  • To get information about all snapshots in a registered repository, use a - * wildcard (*) or _all.
  • - *
  • To get information about any snapshots that are currently running, use - * _current.
  • + *
  • To get information about all snapshots in a registered repository, use a wildcard (*) or _all.
  • + *
  • To get information about any snapshots that are currently running, use _current.
  • *
*

* API name: {@code snapshot} + *

*/ + @Nonnull public final List snapshot() { return this.snapshot; } /** - * If true, returns additional information about each snapshot such as the - * version of OpenSearch which took the snapshot, the start and end times of - * the snapshot, and the number of shards snapshotted. + * If true, returns additional information about each snapshot such as the version of OpenSearch which took the snapshot, + * the start and end times of the snapshot, and the number of shards snapshotted. *

* API name: {@code verbose} + *

*/ @Nullable public final Boolean verbose() { @@ -218,9 +217,11 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder + * 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()); + } + + /** + * If false, the request returns an error for any snapshots that are unavailable. *

* API name: {@code ignore_unavailable} + *

*/ + @Nonnull public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** - * Whether to include the repository name in the snapshot info. Defaults to - * true. - *

- * API name: {@code include_repository} + * This method is left for compatibility. The set value is not used. */ + @Deprecated public final Builder includeRepository(@Nullable Boolean value) { this.includeRepository = value; return this; } /** - * If true, returns additional information about each index in the snapshot - * comprising the number of shards in the index, the total size of the index in - * bytes, and the maximum number of segments per shard in the index. Defaults to - * false, meaning that this information is omitted. - *

- * API name: {@code index_details} - */ + * This method is left for compatibility. The set value is not used. + */ + @Deprecated public final Builder indexDetails(@Nullable Boolean value) { this.indexDetails = 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(@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; + return 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(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Required - Comma-separated list of snapshot repository names used to limit - * the request. Wildcard (*) expressions are supported. + * Required - Comma-separated list of snapshot repository names used to limit the request. Wildcard (*) expressions are supported. *

* API name: {@code repository} + *

*/ + @Nonnull public final Builder repository(String value) { this.repository = value; return this; } /** - * Required - Comma-separated list of snapshot names to retrieve. Also accepts - * wildcards (*). + * Required - + *

+ * Comma-separated list of snapshot names to retrieve. Also accepts wildcards (*). + *

*
    - *
  • To get information about all snapshots in a registered repository, use a - * wildcard (*) or _all.
  • - *
  • To get information about any snapshots that are currently running, use - * _current.
  • + *
  • To get information about all snapshots in a registered repository, use a wildcard (*) or _all.
  • + *
  • To get information about any snapshots that are currently running, use _current.
  • *
*

* 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; } /** - * Required - Comma-separated list of snapshot names to retrieve. Also accepts - * wildcards (*). + * Required - + *

+ * Comma-separated list of snapshot names to retrieve. Also accepts wildcards (*). + *

*
    - *
  • To get information about all snapshots in a registered repository, use a - * wildcard (*) or _all.
  • - *
  • To get information about any snapshots that are currently running, use - * _current.
  • + *
  • To get information about all snapshots in a registered repository, use a wildcard (*) or _all.
  • + *
  • To get information about any snapshots that are currently running, use _current.
  • *
*

* 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; } /** - * If true, returns additional information about each snapshot such as the - * version of OpenSearch which took the snapshot, the start and end times of - * the snapshot, and the number of shards snapshotted. + * If true, returns additional information about each snapshot such as the version of OpenSearch which took the + * snapshot, the start and end times of the snapshot, and the number of shards snapshotted. *

* API name: {@code verbose} + *

*/ + @Nonnull public final Builder verbose(@Nullable Boolean value) { this.verbose = value; return this; @@ -389,9 +401,10 @@ public final Builder verbose(@Nullable Boolean value) { /** * Builds a {@link GetSnapshotRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public GetSnapshotRequest build() { _checkSingleUse(); @@ -405,53 +418,28 @@ public GetSnapshotRequest build() { * Endpoint "{@code snapshot.get}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // 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.stream().map(v -> v).collect(Collectors.joining(",")), buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_snapshot/"); + SimpleEndpoint.pathEncode(request.repository, buf); + buf.append("/"); + SimpleEndpoint.pathEncode(String.join(",", 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.includeRepository != null) { - params.put("include_repository", String.valueOf(request.includeRepository)); - } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } - if (request.indexDetails != null) { - params.put("index_details", String.valueOf(request.indexDetails)); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); } if (request.human != null) { params.put("human", String.valueOf(request.human)); @@ -460,10 +448,34 @@ public GetSnapshotRequest build() { params.put("verbose", String.valueOf(request.verbose)); } return params; - }, SimpleEndpoint.emptyMap(), false, GetSnapshotResponse._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 + this.repository.hashCode(); + result = 31 * result + this.snapshot.hashCode(); + result = 31 * result + Objects.hashCode(this.verbose); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + GetSnapshotRequest other = (GetSnapshotRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && this.repository.equals(other.repository) + && this.snapshot.equals(other.snapshot) + && Objects.equals(this.verbose, other.verbose); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java index 7fb3c8a635..d03ab6eccb 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java @@ -30,12 +30,18 @@ * 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.Collections; import java.util.List; import java.util.function.Function; -import javax.annotation.Nullable; +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; @@ -50,68 +56,62 @@ // typedef: snapshot.get.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetSnapshotResponse implements PlainJsonSerializable { - private final List responses; + @Nonnull private final List snapshots; - private final int total; - - private final int remaining; - // --------------------------------------------------------------------------------------------- private GetSnapshotResponse(Builder builder) { - - this.responses = ApiTypeHelper.unmodifiable(builder.responses); - this.snapshots = ApiTypeHelper.unmodifiable(builder.snapshots); - this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - this.remaining = ApiTypeHelper.requireNonNull(builder.remaining, this, "remaining"); - + this.snapshots = ApiTypeHelper.unmodifiableRequired(builder.snapshots, this, "snapshots"); } - public static GetSnapshotResponse of(Function> fn) { + public static GetSnapshotResponse of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * API name: {@code responses} + * This method is left for compatibility. Always returns an empty list. */ + @Deprecated public final List responses() { - return this.responses; + return Collections.emptyList(); } /** - * API name: {@code snapshots} + * Required - API name: {@code snapshots} */ + @Nonnull public final List snapshots() { return this.snapshots; } /** - * Required - The total number of snapshots that match the request when ignoring - * size limit or after query parameter. + * * This method is left for compatibility. *

* API name: {@code total} */ + @Deprecated public final int total() { - return this.total; + return this.snapshots.size(); } /** - * Required - The number of remaining snapshots that were not returned due to - * size limits and that can be fetched by additional requests using the next - * field value. + * This method is left for compatibility. Always returns 0. *

* API name: {@code remaining} */ + @Deprecated public final int remaining() { - return this.remaining; + return 0; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -119,33 +119,12 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.responses)) { - generator.writeKey("responses"); - generator.writeStartArray(); - for (SnapshotResponseItem item0 : this.responses) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - } - if (ApiTypeHelper.isDefined(this.snapshots)) { - generator.writeKey("snapshots"); - generator.writeStartArray(); - for (SnapshotInfo item0 : this.snapshots) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - + generator.writeKey("snapshots"); + generator.writeStartArray(); + for (SnapshotInfo item0 : this.snapshots) { + item0.serialize(generator, mapper); } - generator.writeKey("total"); - generator.write(this.total); - - generator.writeKey("remaining"); - generator.write(this.remaining); - + generator.writeEnd(); } // --------------------------------------------------------------------------------------------- @@ -153,105 +132,54 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link GetSnapshotResponse}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private List responses; - - @Nullable private List snapshots; - private Integer total; - - private Integer remaining; - /** - * API name: {@code responses} - *

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

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

- * Adds a value to responses using a builder lambda. - */ - public final Builder responses(Function> fn) { - return responses(fn.apply(new SnapshotResponseItem.Builder()).build()); - } - - /** - * API name: {@code snapshots} + * Required - API name: {@code snapshots} + * *

* Adds all elements of list to snapshots. + *

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

* Adds one or more values to snapshots. + *

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

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

*/ + @Nonnull public final Builder snapshots(Function> fn) { return snapshots(fn.apply(new SnapshotInfo.Builder()).build()); } - /** - * Required - The total number of snapshots that match the request when ignoring - * size limit or after query parameter. - *

- * API name: {@code total} - */ - public final Builder total(int value) { - this.total = value; - return this; - } - - /** - * Required - The number of remaining snapshots that were not returned due to - * size limits and that can be fetched by additional requests using the next - * field value. - *

- * API name: {@code remaining} - */ - public final Builder remaining(int value) { - this.remaining = value; - return this; - } - /** * Builds a {@link GetSnapshotResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public GetSnapshotResponse build() { _checkSingleUse(); @@ -270,12 +198,21 @@ public GetSnapshotResponse build() { ); protected static void setupGetSnapshotResponseDeserializer(ObjectDeserializer op) { - - op.add(Builder::responses, JsonpDeserializer.arrayDeserializer(SnapshotResponseItem._DESERIALIZER), "responses"); op.add(Builder::snapshots, JsonpDeserializer.arrayDeserializer(SnapshotInfo._DESERIALIZER), "snapshots"); - op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); - op.add(Builder::remaining, JsonpDeserializer.integerDeserializer(), "remaining"); + } + @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; + GetSnapshotResponse other = (GetSnapshotResponse) o; + return this.snapshots.equals(other.snapshots); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/IndexDetails.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/IndexDetails.java index be058253b5..91dd614b9c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/IndexDetails.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/IndexDetails.java @@ -47,6 +47,7 @@ // typedef: snapshot._types.IndexDetails +@Deprecated @JsonpDeserializable public class IndexDetails implements PlainJsonSerializable { private final int shardCount; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/InfoFeatureState.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/InfoFeatureState.java index 1f46badd72..9ab998cf97 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/InfoFeatureState.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/InfoFeatureState.java @@ -47,6 +47,7 @@ // typedef: snapshot._types.InfoFeatureState +@Deprecated @JsonpDeserializable public class InfoFeatureState implements PlainJsonSerializable { private final String featureName; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java index fe4f7ff412..88582ca5ef 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java @@ -30,12 +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.Collections; 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; @@ -50,10 +58,13 @@ import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: snapshot._types.SnapshotInfo +// typedef: snapshot.SnapshotInfo @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class SnapshotInfo implements PlainJsonSerializable { + + @Nonnull private final List dataStreams; @Nullable @@ -68,28 +79,33 @@ public class SnapshotInfo implements PlainJsonSerializable { @Nullable private final String endTimeInMillis; + @Nonnull private final List failures; @Nullable private final Boolean includeGlobalState; + @Nonnull private final List indices; - private final Map indexDetails; - + @Nonnull private final Map metadata; @Nullable - private final String reason; + private final Long pinnedTimestamp; @Nullable - private final String repository; + private final String reason; - private final String snapshot; + @Nullable + private final Boolean remoteStoreIndexShallowCopy; @Nullable private final ShardStatistics shards; + @Nonnull + private final String snapshot; + @Nullable private final Time startTime; @@ -99,6 +115,7 @@ public class SnapshotInfo implements PlainJsonSerializable { @Nullable private final String state; + @Nonnull private final String uuid; @Nullable @@ -107,12 +124,9 @@ public class SnapshotInfo implements PlainJsonSerializable { @Nullable private final Long versionId; - private final List featureStates; - // --------------------------------------------------------------------------------------------- private SnapshotInfo(Builder builder) { - this.dataStreams = ApiTypeHelper.unmodifiableRequired(builder.dataStreams, this, "dataStreams"); this.duration = builder.duration; this.durationInMillis = builder.durationInMillis; @@ -120,30 +134,29 @@ private SnapshotInfo(Builder builder) { this.endTimeInMillis = builder.endTimeInMillis; this.failures = ApiTypeHelper.unmodifiable(builder.failures); this.includeGlobalState = builder.includeGlobalState; - this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); - this.indexDetails = ApiTypeHelper.unmodifiable(builder.indexDetails); + this.indices = ApiTypeHelper.unmodifiable(builder.indices); this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); + this.pinnedTimestamp = builder.pinnedTimestamp; this.reason = builder.reason; - this.repository = builder.repository; - this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); + this.remoteStoreIndexShallowCopy = builder.remoteStoreIndexShallowCopy; this.shards = builder.shards; + this.snapshot = ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot"); this.startTime = builder.startTime; this.startTimeInMillis = builder.startTimeInMillis; this.state = builder.state; this.uuid = ApiTypeHelper.requireNonNull(builder.uuid, this, "uuid"); this.version = builder.version; this.versionId = builder.versionId; - this.featureStates = ApiTypeHelper.unmodifiable(builder.featureStates); - } - public static SnapshotInfo of(Function> fn) { + public static SnapshotInfo of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code data_streams} */ + @Nonnull public final List dataStreams() { return this.dataStreams; } @@ -183,6 +196,7 @@ public final String endTimeInMillis() { /** * API name: {@code failures} */ + @Nonnull public final List failures() { return this.failures; } @@ -196,47 +210,51 @@ public final Boolean includeGlobalState() { } /** - * Required - API name: {@code indices} + * API name: {@code indices} */ + @Nonnull public final List indices() { return this.indices; } /** - * API name: {@code index_details} + * This method is left for compatibility. Always returns an empty map. */ + @Deprecated public final Map indexDetails() { - return this.indexDetails; + return Collections.emptyMap(); } /** * API name: {@code metadata} */ + @Nonnull public final Map metadata() { return this.metadata; } /** - * API name: {@code reason} + * API name: {@code pinned_timestamp} */ @Nullable - public final String reason() { - return this.reason; + public final Long pinnedTimestamp() { + return this.pinnedTimestamp; } /** - * API name: {@code repository} + * API name: {@code reason} */ @Nullable - public final String repository() { - return this.repository; + public final String reason() { + return this.reason; } /** - * Required - API name: {@code snapshot} + * API name: {@code remote_store_index_shallow_copy} */ - public final String snapshot() { - return this.snapshot; + @Nullable + public final Boolean remoteStoreIndexShallowCopy() { + return this.remoteStoreIndexShallowCopy; } /** @@ -247,6 +265,14 @@ public final ShardStatistics shards() { return this.shards; } + /** + * Required - API name: {@code snapshot} + */ + @Nonnull + public final String snapshot() { + return this.snapshot; + } + /** * API name: {@code start_time} */ @@ -274,6 +300,7 @@ public final String state() { /** * Required - API name: {@code uuid} */ + @Nonnull public final String uuid() { return this.uuid; } @@ -295,15 +322,17 @@ public final Long versionId() { } /** - * API name: {@code feature_states} + * This method is left for compatibility. Always returns an empty list. */ + @Deprecated public final List featureStates() { - return this.featureStates; + return Collections.emptyList(); } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -311,141 +340,116 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.dataStreams)) { - generator.writeKey("data_streams"); - generator.writeStartArray(); - for (String item0 : this.dataStreams) { - generator.write(item0); - - } - generator.writeEnd(); - + generator.writeKey("data_streams"); + generator.writeStartArray(); + for (String item0 : this.dataStreams) { + generator.write(item0); } + generator.writeEnd(); + if (this.duration != null) { generator.writeKey("duration"); this.duration.serialize(generator, mapper); - } + if (this.durationInMillis != null) { generator.writeKey("duration_in_millis"); generator.write(this.durationInMillis); - } + if (this.endTime != null) { generator.writeKey("end_time"); this.endTime.serialize(generator, mapper); - } + if (this.endTimeInMillis != null) { generator.writeKey("end_time_in_millis"); generator.write(this.endTimeInMillis); - } + if (ApiTypeHelper.isDefined(this.failures)) { generator.writeKey("failures"); generator.writeStartArray(); for (SnapshotShardFailure item0 : this.failures) { item0.serialize(generator, mapper); - } generator.writeEnd(); - } + 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.indexDetails)) { - generator.writeKey("index_details"); - generator.writeStartObject(); - for (Map.Entry item0 : this.indexDetails.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - 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.pinnedTimestamp != null) { + generator.writeKey("pinned_timestamp"); + generator.write(this.pinnedTimestamp); } + if (this.reason != null) { generator.writeKey("reason"); generator.write(this.reason); - } - if (this.repository != null) { - generator.writeKey("repository"); - generator.write(this.repository); + if (this.remoteStoreIndexShallowCopy != null) { + generator.writeKey("remote_store_index_shallow_copy"); + generator.write(this.remoteStoreIndexShallowCopy); } - generator.writeKey("snapshot"); - generator.write(this.snapshot); if (this.shards != null) { generator.writeKey("shards"); this.shards.serialize(generator, mapper); - } + + generator.writeKey("snapshot"); + generator.write(this.snapshot); + if (this.startTime != null) { generator.writeKey("start_time"); this.startTime.serialize(generator, mapper); - } + if (this.startTimeInMillis != null) { generator.writeKey("start_time_in_millis"); generator.write(this.startTimeInMillis); - } + if (this.state != null) { generator.writeKey("state"); generator.write(this.state); - } + generator.writeKey("uuid"); generator.write(this.uuid); if (this.version != null) { generator.writeKey("version"); generator.write(this.version); - } + if (this.versionId != null) { generator.writeKey("version_id"); generator.write(this.versionId); - } - if (ApiTypeHelper.isDefined(this.featureStates)) { - generator.writeKey("feature_states"); - generator.writeStartArray(); - for (InfoFeatureState item0 : this.featureStates) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - } - } // --------------------------------------------------------------------------------------------- @@ -456,69 +460,51 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private List dataStreams; - @Nullable private Time duration; - @Nullable private String durationInMillis; - @Nullable private Time endTime; - @Nullable private String endTimeInMillis; - @Nullable private List failures; - @Nullable private Boolean includeGlobalState; - - private List indices; - @Nullable - private Map indexDetails; - + private List indices; @Nullable private Map metadata; - + @Nullable + private Long pinnedTimestamp; @Nullable private String reason; - @Nullable - private String repository; - - private String snapshot; - + private Boolean remoteStoreIndexShallowCopy; @Nullable private ShardStatistics shards; - + private String snapshot; @Nullable private Time startTime; - @Nullable private String startTimeInMillis; - @Nullable private String state; - private String uuid; - @Nullable private String version; - @Nullable private Long versionId; - @Nullable - private List featureStates; - /** * Required - API name: {@code data_streams} + * *

* Adds all elements of list to dataStreams. + *

*/ + @Nonnull public final Builder dataStreams(List list) { this.dataStreams = _listAddAll(this.dataStreams, list); return this; @@ -526,9 +512,12 @@ public final Builder dataStreams(List list) { /** * Required - API name: {@code data_streams} + * *

* Adds one or more values to dataStreams. + *

*/ + @Nonnull public final Builder dataStreams(String value, String... values) { this.dataStreams = _listAdd(this.dataStreams, value, values); return this; @@ -537,6 +526,7 @@ public final Builder dataStreams(String value, String... values) { /** * API name: {@code duration} */ + @Nonnull public final Builder duration(@Nullable Time value) { this.duration = value; return this; @@ -545,13 +535,15 @@ public final Builder duration(@Nullable Time value) { /** * API name: {@code duration} */ + @Nonnull public final Builder duration(Function> fn) { - return this.duration(fn.apply(new Time.Builder()).build()); + return duration(fn.apply(new Time.Builder()).build()); } /** * API name: {@code duration_in_millis} */ + @Nonnull public final Builder durationInMillis(@Nullable String value) { this.durationInMillis = value; return this; @@ -560,21 +552,16 @@ public final Builder durationInMillis(@Nullable String value) { /** * API name: {@code end_time} */ + @Nonnull public final Builder endTime(@Nullable Time value) { this.endTime = value; return this; } - /** - * API name: {@code end_time} - */ - public final Builder endTime(Function> fn) { - return this.endTime(fn.apply(new Time.Builder()).build()); - } - /** * API name: {@code end_time_in_millis} */ + @Nonnull public final Builder endTimeInMillis(@Nullable String value) { this.endTimeInMillis = value; return this; @@ -582,9 +569,12 @@ public final Builder endTimeInMillis(@Nullable String value) { /** * API name: {@code failures} + * *

* Adds all elements of list to failures. + *

*/ + @Nonnull public final Builder failures(List list) { this.failures = _listAddAll(this.failures, list); return this; @@ -592,9 +582,12 @@ public final Builder failures(List list) { /** * API name: {@code failures} + * *

* Adds one or more values to failures. + *

*/ + @Nonnull public final Builder failures(SnapshotShardFailure value, SnapshotShardFailure... values) { this.failures = _listAdd(this.failures, value, values); return this; @@ -602,9 +595,12 @@ public final Builder failures(SnapshotShardFailure value, SnapshotShardFailure.. /** * API name: {@code failures} + * *

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

*/ + @Nonnull public final Builder failures(Function> fn) { return failures(fn.apply(new SnapshotShardFailure.Builder()).build()); } @@ -612,65 +608,46 @@ public final Builder failures(Function * Adds all elements of list to indices. + *

*/ + @Nonnull public final Builder indices(List list) { this.indices = _listAddAll(this.indices, list); return this; } /** - * Required - API name: {@code indices} + * 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; } - /** - * API name: {@code index_details} - *

- * Adds all entries of map to indexDetails. - */ - public final Builder indexDetails(Map map) { - this.indexDetails = _mapPutAll(this.indexDetails, map); - return this; - } - - /** - * API name: {@code index_details} - *

- * Adds an entry to indexDetails. - */ - public final Builder indexDetails(String key, IndexDetails value) { - this.indexDetails = _mapPut(this.indexDetails, key, value); - return this; - } - - /** - * API name: {@code index_details} - *

- * Adds an entry to indexDetails using a builder lambda. - */ - public final Builder indexDetails(String key, Function> fn) { - return indexDetails(key, fn.apply(new IndexDetails.Builder()).build()); - } - /** * 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; @@ -678,41 +655,48 @@ public final Builder metadata(Map map) { /** * 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; } /** - * API name: {@code reason} + * API name: {@code pinned_timestamp} */ - public final Builder reason(@Nullable String value) { - this.reason = value; + @Nonnull + public final Builder pinnedTimestamp(@Nullable Long value) { + this.pinnedTimestamp = value; return this; } /** - * API name: {@code repository} + * API name: {@code reason} */ - public final Builder repository(@Nullable String value) { - this.repository = value; + @Nonnull + public final Builder reason(@Nullable String value) { + this.reason = value; return this; } /** - * Required - API name: {@code snapshot} + * API name: {@code remote_store_index_shallow_copy} */ - public final Builder snapshot(String value) { - this.snapshot = value; + @Nonnull + public final Builder remoteStoreIndexShallowCopy(@Nullable Boolean value) { + this.remoteStoreIndexShallowCopy = value; return this; } /** * API name: {@code shards} */ + @Nonnull public final Builder shards(@Nullable ShardStatistics value) { this.shards = value; return this; @@ -721,28 +705,33 @@ public final Builder shards(@Nullable ShardStatistics value) { /** * 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()); } /** - * API name: {@code start_time} + * Required - API name: {@code snapshot} */ - public final Builder startTime(@Nullable Time value) { - this.startTime = value; + @Nonnull + public final Builder snapshot(String value) { + this.snapshot = value; return this; } /** * API name: {@code start_time} */ - public final Builder startTime(Function> fn) { - return this.startTime(fn.apply(new Time.Builder()).build()); + @Nonnull + public final Builder startTime(@Nullable Time value) { + this.startTime = value; + return this; } /** * API name: {@code start_time_in_millis} */ + @Nonnull public final Builder startTimeInMillis(@Nullable String value) { this.startTimeInMillis = value; return this; @@ -751,6 +740,7 @@ public final Builder startTimeInMillis(@Nullable String value) { /** * API name: {@code state} */ + @Nonnull public final Builder state(@Nullable String value) { this.state = value; return this; @@ -759,6 +749,7 @@ public final Builder state(@Nullable String value) { /** * Required - API name: {@code uuid} */ + @Nonnull public final Builder uuid(String value) { this.uuid = value; return this; @@ -767,6 +758,7 @@ public final Builder uuid(String value) { /** * API name: {@code version} */ + @Nonnull public final Builder version(@Nullable String value) { this.version = value; return this; @@ -775,46 +767,19 @@ public final Builder version(@Nullable String value) { /** * API name: {@code version_id} */ + @Nonnull public final Builder versionId(@Nullable Long value) { this.versionId = value; return this; } - /** - * API name: {@code feature_states} - *

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

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

- * Adds a value to featureStates using a builder lambda. - */ - public final Builder featureStates(Function> fn) { - return featureStates(fn.apply(new InfoFeatureState.Builder()).build()); - } - /** * Builds a {@link SnapshotInfo}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public SnapshotInfo build() { _checkSingleUse(); @@ -833,7 +798,6 @@ public SnapshotInfo build() { ); protected static void setupSnapshotInfoDeserializer(ObjectDeserializer op) { - op.add(Builder::dataStreams, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "data_streams"); op.add(Builder::duration, Time._DESERIALIZER, "duration"); op.add(Builder::durationInMillis, JsonpDeserializer.stringDeserializer(), "duration_in_millis"); @@ -842,20 +806,70 @@ protected static void setupSnapshotInfoDeserializer(ObjectDeserializer> fn) { + public static SnapshotShardFailure of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code index} */ + @Nonnull public final String index() { return this.index; } /** - * Required - API name: {@code node_id} + * API name: {@code node_id} */ + @Nullable public final String nodeId() { return this.nodeId; } @@ -91,6 +106,7 @@ public final String nodeId() { /** * Required - API name: {@code reason} */ + @Nonnull public final String reason() { return this.reason; } @@ -98,6 +114,7 @@ public final String reason() { /** * Required - API name: {@code shard_id} */ + @Nonnull public final String shardId() { return this.shardId; } @@ -105,6 +122,7 @@ public final String shardId() { /** * Required - API name: {@code status} */ + @Nonnull public final String status() { return this.status; } @@ -112,6 +130,7 @@ public final String status() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -119,12 +138,13 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("index"); generator.write(this.index); - generator.writeKey("node_id"); - generator.write(this.nodeId); + if (this.nodeId != null) { + generator.writeKey("node_id"); + generator.write(this.nodeId); + } generator.writeKey("reason"); generator.write(this.reason); @@ -134,7 +154,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("status"); generator.write(this.status); - } // --------------------------------------------------------------------------------------------- @@ -142,30 +161,28 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link SnapshotShardFailure}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private String index; - + @Nullable private String nodeId; - private String reason; - private String shardId; - private String status; /** * Required - API name: {@code index} */ + @Nonnull public final Builder index(String value) { this.index = value; return this; } /** - * Required - API name: {@code node_id} + * API name: {@code node_id} */ - public final Builder nodeId(String value) { + @Nonnull + public final Builder nodeId(@Nullable String value) { this.nodeId = value; return this; } @@ -173,6 +190,7 @@ public final Builder nodeId(String value) { /** * Required - API name: {@code reason} */ + @Nonnull public final Builder reason(String value) { this.reason = value; return this; @@ -181,6 +199,7 @@ public final Builder reason(String value) { /** * Required - API name: {@code shard_id} */ + @Nonnull public final Builder shardId(String value) { this.shardId = value; return this; @@ -189,6 +208,7 @@ public final Builder shardId(String value) { /** * Required - API name: {@code status} */ + @Nonnull public final Builder status(String value) { this.status = value; return this; @@ -197,9 +217,10 @@ public final Builder status(String value) { /** * Builds a {@link SnapshotShardFailure}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public SnapshotShardFailure build() { _checkSingleUse(); @@ -218,13 +239,33 @@ public SnapshotShardFailure build() { ); protected static void setupSnapshotShardFailureDeserializer(ObjectDeserializer op) { - op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); op.add(Builder::nodeId, JsonpDeserializer.stringDeserializer(), "node_id"); op.add(Builder::reason, JsonpDeserializer.stringDeserializer(), "reason"); op.add(Builder::shardId, JsonpDeserializer.stringDeserializer(), "shard_id"); op.add(Builder::status, JsonpDeserializer.stringDeserializer(), "status"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.index.hashCode(); + result = 31 * result + Objects.hashCode(this.nodeId); + result = 31 * result + this.reason.hashCode(); + result = 31 * result + this.shardId.hashCode(); + result = 31 * result + this.status.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotShardFailure other = (SnapshotShardFailure) o; + return this.index.equals(other.index) + && Objects.equals(this.nodeId, other.nodeId) + && this.reason.equals(other.reason) + && this.shardId.equals(other.shardId) + && this.status.equals(other.status); + } } 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 a4f4818b34..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 @@ -204,6 +204,8 @@ private static String classBaseName(@Nonnull OperationGroup operationGroup) { return "CloneSnapshot"; case "snapshot.create": return "CreateSnapshot"; + case "snapshot.get": + return "GetSnapshot"; case "tasks.get": return "GetTasks"; default: