From 1c7c6e065b22b4a275a335f13eb06aa17ec20a87 Mon Sep 17 00:00:00 2001 From: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> Date: Wed, 27 Nov 2024 05:57:42 +0900 Subject: [PATCH] Generate GetSnapshot (#1299) * Generate get snapshot Signed-off-by: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> * add changelog Signed-off-by: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> * Update codegen Signed-off-by: Thomas Farr --------- Signed-off-by: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> Signed-off-by: Thomas Farr Co-authored-by: Thomas Farr --- CHANGELOG.md | 3 +- .../snapshot/GetSnapshotRequest.java | 367 ++++++------ .../snapshot/GetSnapshotResponse.java | 202 +++---- .../OpenSearchSnapshotAsyncClientBase.java | 19 + .../OpenSearchSnapshotClientBase.java | 19 + .../opensearch/snapshot/SnapshotInfo.java | 537 ++++++++++-------- .../snapshot/SnapshotShardFailure.java | 122 +++- .../opensearch/snapshot/IndexDetails.java | 212 ------- .../opensearch/snapshot/InfoFeatureState.java | 179 ------ .../OpenSearchSnapshotAsyncClient.java | 32 -- .../snapshot/OpenSearchSnapshotClient.java | 32 -- .../client/codegen/CodeGenerator.java | 2 +- .../client/codegen/model/RequestShape.java | 2 + 13 files changed, 681 insertions(+), 1047 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.java (58%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java (50%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java (63%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/snapshot/SnapshotShardFailure.java (66%) delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/snapshot/IndexDetails.java delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/snapshot/InfoFeatureState.java diff --git a/CHANGELOG.md b/CHANGELOG.md index d475c6b861..0a2faa175a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,8 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Fixed - 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 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)) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.java similarity index 58% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.java index 79fa89d264..3b1776a93b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotRequest.java +++ b/java-client/src/generated/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; @@ -44,38 +50,33 @@ 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.Request /** * Returns information about a snapshot. - * */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class GetSnapshotRequest extends RequestBase implements ToCopyableBuilder { -public class GetSnapshotRequest extends RequestBase { @Nullable - private final Boolean human; + private final Time clusterManagerTimeout; @Nullable private final Boolean ignoreUnavailable; - @Nullable - private final Boolean includeRepository; - - @Nullable - private final Boolean indexDetails; - @Deprecated @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - + @Nonnull private final String repository; + @Nonnull private final List snapshot; @Nullable @@ -84,36 +85,34 @@ public class GetSnapshotRequest extends RequestBase { // --------------------------------------------------------------------------------------------- private GetSnapshotRequest(Builder builder) { - - this.human = builder.human; + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.ignoreUnavailable = builder.ignoreUnavailable; - this.includeRepository = builder.includeRepository; - this.indexDetails = builder.indexDetails; this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository"); this.snapshot = ApiTypeHelper.unmodifiableRequired(builder.snapshot, this, "snapshot"); this.verbose = builder.verbose; - } - 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 +120,11 @@ public final Boolean ignoreUnavailable() { } /** - * Whether to include the repository name in the snapshot info. Defaults to - * true. - *

- * API name: {@code include_repository} - */ - @Nullable - 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} - */ - @Nullable - 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 +133,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() { @@ -207,180 +175,186 @@ public final Boolean verbose() { // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link GetSnapshotRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable - private Boolean human; - + private Time clusterManagerTimeout; @Nullable private Boolean ignoreUnavailable; - - @Nullable - private Boolean includeRepository; - - @Nullable - private Boolean indexDetails; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - private String repository; - private List snapshot; - @Nullable private Boolean verbose; - /** - * API name: {@code human} - */ - public final Builder human(@Nullable Boolean value) { - this.human = value; - return this; + public Builder() {} + + private Builder(GetSnapshotRequest o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.ignoreUnavailable = o.ignoreUnavailable; + this.masterTimeout = o.masterTimeout; + this.repository = o.repository; + this.snapshot = _listCopy(o.snapshot); + this.verbose = o.verbose; + } + + 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); + this.verbose = o.verbose; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); } /** - * If false, the request returns an error for any snapshots that are - * unavailable. + * 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; } /** - * Whether to include the repository name in the snapshot info. Defaults to - * true. + * Operation timeout for connection to cluster-manager node. *

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

*/ - public final Builder includeRepository(@Nullable Boolean value) { - this.includeRepository = value; - return this; + @Nonnull + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); } /** - * 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. + * If false, the request returns an error for any snapshots that are unavailable. *

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

*/ - public final Builder indexDetails(@Nullable Boolean value) { - this.indexDetails = value; + @Nonnull + public final Builder ignoreUnavailable(@Nullable Boolean value) { + this.ignoreUnavailable = 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()); + 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(@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()); - } - - /** - * 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 +363,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,65 +380,61 @@ 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.human != null) { - params.put("human", String.valueOf(request.human)); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); } if (request.verbose != null) { 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/generated/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java similarity index 50% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java index 7fb3c8a635..253287d4c3 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/GetSnapshotResponse.java @@ -30,88 +30,60 @@ * 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.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; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.opensearch.snapshot.get.SnapshotResponseItem; 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.Response @JsonpDeserializable -public class GetSnapshotResponse implements PlainJsonSerializable { - private final List responses; +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class GetSnapshotResponse implements PlainJsonSerializable, ToCopyableBuilder { + @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} - */ - public final List responses() { - return this.responses; - } - - /** - * 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. - *

- * API name: {@code total} - */ - public final int total() { - return this.total; - } - - /** - * 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 int remaining() { - return this.remaining; - } - /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -119,139 +91,94 @@ 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.writeEnd(); + } - generator.writeKey("remaining"); - generator.write(this.remaining); + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link GetSnapshotResponse}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private List responses; - - @Nullable + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private List snapshots; - private Integer total; + public Builder() {} - 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; + private Builder(GetSnapshotResponse o) { + this.snapshots = _listCopy(o.snapshots); } - /** - * 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; + private Builder(Builder o) { + this.snapshots = _listCopy(o.snapshots); } - /** - * 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()); + @Override + @Nonnull + public Builder copy() { + return new Builder(this); } /** - * 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 +197,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/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotAsyncClientBase.java index 9b3d4531ed..ce3ca27aca 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,25 @@ public final CompletableFuture clone( return clone(fn.apply(new CloneSnapshotRequest.Builder()).build()); } + // ----- Endpoint: snapshot.get + + /** + * Returns information about a snapshot. + */ + public CompletableFuture get(GetSnapshotRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, GetSnapshotRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about a snapshot. + * + * @param fn a function that initializes a builder to create the {@link GetSnapshotRequest} + */ + public final CompletableFuture get(Function> fn) + throws IOException, OpenSearchException { + return get(fn.apply(new GetSnapshotRequest.Builder()).build()); + } + // ----- Endpoint: snapshot.verify_repository /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/OpenSearchSnapshotClientBase.java index b894dceea1..50ca8e3870 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 get(fn.apply(new GetSnapshotRequest.Builder()).build()); + } + // ----- Endpoint: snapshot.verify_repository /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java similarity index 63% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java index fe4f7ff412..2d0a9574b8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotInfo.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.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; @@ -47,58 +54,69 @@ import org.opensearch.client.opensearch._types.ShardStatistics; 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.SnapshotInfo +// typedef: snapshot.SnapshotInfo @JsonpDeserializable -public class SnapshotInfo implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotInfo implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull private final List dataStreams; @Nullable private final Time duration; @Nullable - private final String durationInMillis; + private final Long durationInMillis; @Nullable - private final Time endTime; + private final String endTime; @Nullable - private final String endTimeInMillis; + private final Long 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; + private final String startTime; @Nullable - private final String startTimeInMillis; + private final Long startTimeInMillis; @Nullable private final String state; + @Nonnull private final String uuid; @Nullable @@ -107,12 +125,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 +135,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; } @@ -160,7 +174,7 @@ public final Time duration() { * API name: {@code duration_in_millis} */ @Nullable - public final String durationInMillis() { + public final Long durationInMillis() { return this.durationInMillis; } @@ -168,7 +182,7 @@ public final String durationInMillis() { * API name: {@code end_time} */ @Nullable - public final Time endTime() { + public final String endTime() { return this.endTime; } @@ -176,13 +190,14 @@ public final Time endTime() { * API name: {@code end_time_in_millis} */ @Nullable - public final String endTimeInMillis() { + public final Long endTimeInMillis() { return this.endTimeInMillis; } /** * API name: {@code failures} */ + @Nonnull public final List failures() { return this.failures; } @@ -196,47 +211,43 @@ 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} - */ - public final Map indexDetails() { - return this.indexDetails; - } - /** * 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,11 +258,19 @@ 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} */ @Nullable - public final Time startTime() { + public final String startTime() { return this.startTime; } @@ -259,7 +278,7 @@ public final Time startTime() { * API name: {@code start_time_in_millis} */ @Nullable - public final String startTimeInMillis() { + public final Long startTimeInMillis() { return this.startTimeInMillis; } @@ -274,6 +293,7 @@ public final String state() { /** * Required - API name: {@code uuid} */ + @Nonnull public final String uuid() { return this.uuid; } @@ -294,16 +314,10 @@ public final Long versionId() { return this.versionId; } - /** - * API name: {@code feature_states} - */ - public final List featureStates() { - return this.featureStates; - } - /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -311,214 +325,235 @@ 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); - + generator.write(this.endTime); } + 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); - + generator.write(this.startTime); } + 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(); + } - } + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link SnapshotInfo}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private List dataStreams; - @Nullable private Time duration; - @Nullable - private String durationInMillis; - + private Long durationInMillis; @Nullable - private Time endTime; - + private String endTime; @Nullable - private String endTimeInMillis; - + private Long 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; - + private String startTime; @Nullable - private String startTimeInMillis; - + private Long startTimeInMillis; @Nullable private String state; - private String uuid; - @Nullable private String version; - @Nullable private Long versionId; - @Nullable - private List featureStates; + public Builder() {} + + private Builder(SnapshotInfo o) { + this.dataStreams = _listCopy(o.dataStreams); + this.duration = o.duration; + this.durationInMillis = o.durationInMillis; + this.endTime = o.endTime; + this.endTimeInMillis = o.endTimeInMillis; + this.failures = _listCopy(o.failures); + this.includeGlobalState = o.includeGlobalState; + this.indices = _listCopy(o.indices); + this.metadata = _mapCopy(o.metadata); + this.pinnedTimestamp = o.pinnedTimestamp; + this.reason = o.reason; + this.remoteStoreIndexShallowCopy = o.remoteStoreIndexShallowCopy; + this.shards = o.shards; + this.snapshot = o.snapshot; + this.startTime = o.startTime; + this.startTimeInMillis = o.startTimeInMillis; + this.state = o.state; + this.uuid = o.uuid; + this.version = o.version; + this.versionId = o.versionId; + } + + private Builder(Builder o) { + this.dataStreams = _listCopy(o.dataStreams); + this.duration = o.duration; + this.durationInMillis = o.durationInMillis; + this.endTime = o.endTime; + this.endTimeInMillis = o.endTimeInMillis; + this.failures = _listCopy(o.failures); + this.includeGlobalState = o.includeGlobalState; + this.indices = _listCopy(o.indices); + this.metadata = _mapCopy(o.metadata); + this.pinnedTimestamp = o.pinnedTimestamp; + this.reason = o.reason; + this.remoteStoreIndexShallowCopy = o.remoteStoreIndexShallowCopy; + this.shards = o.shards; + this.snapshot = o.snapshot; + this.startTime = o.startTime; + this.startTimeInMillis = o.startTimeInMillis; + this.state = o.state; + this.uuid = o.uuid; + this.version = o.version; + this.versionId = o.versionId; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } /** * 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 +561,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 +575,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,14 +584,16 @@ 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} */ - public final Builder durationInMillis(@Nullable String value) { + @Nonnull + public final Builder durationInMillis(@Nullable Long value) { this.durationInMillis = value; return this; } @@ -560,31 +601,29 @@ public final Builder durationInMillis(@Nullable String value) { /** * API name: {@code end_time} */ - public final Builder endTime(@Nullable Time value) { + @Nonnull + public final Builder endTime(@Nullable String 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} */ - public final Builder endTimeInMillis(@Nullable String value) { + @Nonnull + public final Builder endTimeInMillis(@Nullable Long value) { this.endTimeInMillis = value; return this; } /** * 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 +631,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 +644,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 +657,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 +704,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,29 +754,34 @@ 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 String value) { + this.startTime = value; + return this; } /** * API name: {@code start_time_in_millis} */ - public final Builder startTimeInMillis(@Nullable String value) { + @Nonnull + public final Builder startTimeInMillis(@Nullable Long value) { this.startTimeInMillis = value; return this; } @@ -751,6 +789,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 +798,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 +807,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 +816,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,29 +847,78 @@ 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"); - op.add(Builder::endTime, Time._DESERIALIZER, "end_time"); - op.add(Builder::endTimeInMillis, JsonpDeserializer.stringDeserializer(), "end_time_in_millis"); + op.add(Builder::durationInMillis, JsonpDeserializer.longDeserializer(), "duration_in_millis"); + op.add(Builder::endTime, JsonpDeserializer.stringDeserializer(), "end_time"); + op.add(Builder::endTimeInMillis, JsonpDeserializer.longDeserializer(), "end_time_in_millis"); op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(SnapshotShardFailure._DESERIALIZER), "failures"); op.add(Builder::includeGlobalState, JsonpDeserializer.booleanDeserializer(), "include_global_state"); op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); - op.add(Builder::indexDetails, JsonpDeserializer.stringMapDeserializer(IndexDetails._DESERIALIZER), "index_details"); op.add(Builder::metadata, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "metadata"); + op.add(Builder::pinnedTimestamp, JsonpDeserializer.longDeserializer(), "pinned_timestamp"); op.add(Builder::reason, JsonpDeserializer.stringDeserializer(), "reason"); - op.add(Builder::repository, JsonpDeserializer.stringDeserializer(), "repository"); - op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); + op.add(Builder::remoteStoreIndexShallowCopy, JsonpDeserializer.booleanDeserializer(), "remote_store_index_shallow_copy"); op.add(Builder::shards, ShardStatistics._DESERIALIZER, "shards"); - op.add(Builder::startTime, Time._DESERIALIZER, "start_time"); - op.add(Builder::startTimeInMillis, JsonpDeserializer.stringDeserializer(), "start_time_in_millis"); + op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); + op.add(Builder::startTime, JsonpDeserializer.stringDeserializer(), "start_time"); + op.add(Builder::startTimeInMillis, JsonpDeserializer.longDeserializer(), "start_time_in_millis"); op.add(Builder::state, JsonpDeserializer.stringDeserializer(), "state"); op.add(Builder::uuid, JsonpDeserializer.stringDeserializer(), "uuid"); op.add(Builder::version, JsonpDeserializer.stringDeserializer(), "version"); op.add(Builder::versionId, JsonpDeserializer.longDeserializer(), "version_id"); - op.add(Builder::featureStates, JsonpDeserializer.arrayDeserializer(InfoFeatureState._DESERIALIZER), "feature_states"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.dataStreams.hashCode(); + result = 31 * result + Objects.hashCode(this.duration); + result = 31 * result + Objects.hashCode(this.durationInMillis); + result = 31 * result + Objects.hashCode(this.endTime); + result = 31 * result + Objects.hashCode(this.endTimeInMillis); + result = 31 * result + Objects.hashCode(this.failures); + result = 31 * result + Objects.hashCode(this.includeGlobalState); + result = 31 * result + Objects.hashCode(this.indices); + result = 31 * result + Objects.hashCode(this.metadata); + result = 31 * result + Objects.hashCode(this.pinnedTimestamp); + result = 31 * result + Objects.hashCode(this.reason); + result = 31 * result + Objects.hashCode(this.remoteStoreIndexShallowCopy); + result = 31 * result + Objects.hashCode(this.shards); + result = 31 * result + this.snapshot.hashCode(); + result = 31 * result + Objects.hashCode(this.startTime); + result = 31 * result + Objects.hashCode(this.startTimeInMillis); + result = 31 * result + Objects.hashCode(this.state); + result = 31 * result + this.uuid.hashCode(); + result = 31 * result + Objects.hashCode(this.version); + result = 31 * result + Objects.hashCode(this.versionId); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SnapshotInfo other = (SnapshotInfo) o; + return this.dataStreams.equals(other.dataStreams) + && Objects.equals(this.duration, other.duration) + && Objects.equals(this.durationInMillis, other.durationInMillis) + && Objects.equals(this.endTime, other.endTime) + && Objects.equals(this.endTimeInMillis, other.endTimeInMillis) + && Objects.equals(this.failures, other.failures) + && Objects.equals(this.includeGlobalState, other.includeGlobalState) + && Objects.equals(this.indices, other.indices) + && Objects.equals(this.metadata, other.metadata) + && Objects.equals(this.pinnedTimestamp, other.pinnedTimestamp) + && Objects.equals(this.reason, other.reason) + && Objects.equals(this.remoteStoreIndexShallowCopy, other.remoteStoreIndexShallowCopy) + && Objects.equals(this.shards, other.shards) + && this.snapshot.equals(other.snapshot) + && Objects.equals(this.startTime, other.startTime) + && Objects.equals(this.startTimeInMillis, other.startTimeInMillis) + && Objects.equals(this.state, other.state) + && this.uuid.equals(other.uuid) + && Objects.equals(this.version, other.version) + && Objects.equals(this.versionId, other.versionId); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotShardFailure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardFailure.java similarity index 66% rename from java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotShardFailure.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardFailure.java index e13b35e127..fccd7e6ebe 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/SnapshotShardFailure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/SnapshotShardFailure.java @@ -30,10 +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.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; @@ -41,49 +49,58 @@ 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.SnapshotShardFailure +// typedef: snapshot.SnapshotShardFailure @JsonpDeserializable -public class SnapshotShardFailure implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class SnapshotShardFailure implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull private final String index; + @Nullable private final String nodeId; + @Nonnull private final String reason; + @Nonnull private final String shardId; + @Nonnull private final String status; // --------------------------------------------------------------------------------------------- private SnapshotShardFailure(Builder builder) { - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.nodeId = ApiTypeHelper.requireNonNull(builder.nodeId, this, "nodeId"); + this.nodeId = builder.nodeId; this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason"); this.shardId = ApiTypeHelper.requireNonNull(builder.shardId, this, "shardId"); this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); - } - public static SnapshotShardFailure of(Function> 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 +108,7 @@ public final String nodeId() { /** * Required - API name: {@code reason} */ + @Nonnull public final String reason() { return this.reason; } @@ -98,6 +116,7 @@ public final String reason() { /** * Required - API name: {@code shard_id} */ + @Nonnull public final String shardId() { return this.shardId; } @@ -105,6 +124,7 @@ public final String shardId() { /** * Required - API name: {@code status} */ + @Nonnull public final String status() { return this.status; } @@ -112,6 +132,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 +140,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,38 +156,70 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("status"); generator.write(this.status); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link SnapshotShardFailure}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private String index; - + @Nullable private String nodeId; - private String reason; - private String shardId; - private String status; + public Builder() {} + + private Builder(SnapshotShardFailure o) { + this.index = o.index; + this.nodeId = o.nodeId; + this.reason = o.reason; + this.shardId = o.shardId; + this.status = o.status; + } + + private Builder(Builder o) { + this.index = o.index; + this.nodeId = o.nodeId; + this.reason = o.reason; + this.shardId = o.shardId; + this.status = o.status; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * 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 +227,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 +236,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 +245,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 +254,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 +276,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-client/src/main/java/org/opensearch/client/opensearch/snapshot/IndexDetails.java b/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/IndexDetails.java deleted file mode 100644 index be058253b5..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/IndexDetails.java +++ /dev/null @@ -1,212 +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 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.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: snapshot._types.IndexDetails - -@JsonpDeserializable -public class IndexDetails implements PlainJsonSerializable { - private final int shardCount; - - @Nullable - private final String size; - - private final long sizeInBytes; - - private final long maxSegmentsPerShard; - - // --------------------------------------------------------------------------------------------- - - private IndexDetails(Builder builder) { - - this.shardCount = ApiTypeHelper.requireNonNull(builder.shardCount, this, "shardCount"); - this.size = builder.size; - this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes"); - this.maxSegmentsPerShard = ApiTypeHelper.requireNonNull(builder.maxSegmentsPerShard, this, "maxSegmentsPerShard"); - - } - - public static IndexDetails of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code shard_count} - */ - public final int shardCount() { - return this.shardCount; - } - - /** - * API name: {@code size} - */ - @Nullable - public final String size() { - return this.size; - } - - /** - * Required - API name: {@code size_in_bytes} - */ - public final long sizeInBytes() { - return this.sizeInBytes; - } - - /** - * Required - API name: {@code max_segments_per_shard} - */ - public final long maxSegmentsPerShard() { - return this.maxSegmentsPerShard; - } - - /** - * 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("shard_count"); - generator.write(this.shardCount); - - if (this.size != null) { - generator.writeKey("size"); - generator.write(this.size); - - } - generator.writeKey("size_in_bytes"); - generator.write(this.sizeInBytes); - - generator.writeKey("max_segments_per_shard"); - generator.write(this.maxSegmentsPerShard); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link IndexDetails}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Integer shardCount; - - @Nullable - private String size; - - private Long sizeInBytes; - - private Long maxSegmentsPerShard; - - /** - * Required - API name: {@code shard_count} - */ - public final Builder shardCount(int value) { - this.shardCount = value; - return this; - } - - /** - * API name: {@code size} - */ - public final Builder size(@Nullable String value) { - this.size = value; - return this; - } - - /** - * Required - API name: {@code size_in_bytes} - */ - public final Builder sizeInBytes(long value) { - this.sizeInBytes = value; - return this; - } - - /** - * Required - API name: {@code max_segments_per_shard} - */ - public final Builder maxSegmentsPerShard(long value) { - this.maxSegmentsPerShard = value; - return this; - } - - /** - * Builds a {@link IndexDetails}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public IndexDetails build() { - _checkSingleUse(); - - return new IndexDetails(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link IndexDetails} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - IndexDetails::setupIndexDetailsDeserializer - ); - - protected static void setupIndexDetailsDeserializer(ObjectDeserializer op) { - - op.add(Builder::shardCount, JsonpDeserializer.integerDeserializer(), "shard_count"); - op.add(Builder::size, JsonpDeserializer.stringDeserializer(), "size"); - op.add(Builder::sizeInBytes, JsonpDeserializer.longDeserializer(), "size_in_bytes"); - op.add(Builder::maxSegmentsPerShard, JsonpDeserializer.longDeserializer(), "max_segments_per_shard"); - - } - -} 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 deleted file mode 100644 index 1f46badd72..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/snapshot/InfoFeatureState.java +++ /dev/null @@ -1,179 +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.List; -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.InfoFeatureState - -@JsonpDeserializable -public class InfoFeatureState implements PlainJsonSerializable { - private final String featureName; - - private final List indices; - - // --------------------------------------------------------------------------------------------- - - private InfoFeatureState(Builder builder) { - - this.featureName = ApiTypeHelper.requireNonNull(builder.featureName, this, "featureName"); - this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); - - } - - public static InfoFeatureState of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code feature_name} - */ - public final String featureName() { - return this.featureName; - } - - /** - * Required - API name: {@code indices} - */ - public final List indices() { - return this.indices; - } - - /** - * 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("feature_name"); - generator.write(this.featureName); - - if (ApiTypeHelper.isDefined(this.indices)) { - generator.writeKey("indices"); - generator.writeStartArray(); - for (String item0 : this.indices) { - generator.write(item0); - - } - generator.writeEnd(); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link InfoFeatureState}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String featureName; - - private List indices; - - /** - * Required - API name: {@code feature_name} - */ - public final Builder featureName(String value) { - this.featureName = value; - return this; - } - - /** - * Required - 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; - } - - /** - * Required - 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; - } - - /** - * Builds a {@link InfoFeatureState}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public InfoFeatureState build() { - _checkSingleUse(); - - return new InfoFeatureState(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link InfoFeatureState} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - InfoFeatureState::setupInfoFeatureStateDeserializer - ); - - protected static void setupInfoFeatureStateDeserializer(ObjectDeserializer op) { - - op.add(Builder::featureName, JsonpDeserializer.stringDeserializer(), "feature_name"); - op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); - - } - -} 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 6e7e3997c9..305d795e6b 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 @@ -195,38 +195,6 @@ public final CompletableFuture deleteRepository( return deleteRepository(fn.apply(new DeleteRepositoryRequest.Builder()).build()); } - // ----- Endpoint: snapshot.get - - /** - * Returns information about a snapshot. - * - * - */ - - public CompletableFuture get(GetSnapshotRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetSnapshotRequest, - GetSnapshotResponse, - ErrorResponse>) GetSnapshotRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about a snapshot. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetSnapshotRequest} - * - */ - - public final CompletableFuture get(Function> fn) - throws IOException, OpenSearchException { - return get(fn.apply(new GetSnapshotRequest.Builder()).build()); - } - // ----- Endpoint: snapshot.get_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 29103dd89f..1491697e93 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 @@ -190,38 +190,6 @@ public final DeleteRepositoryResponse deleteRepository( return deleteRepository(fn.apply(new DeleteRepositoryRequest.Builder()).build()); } - // ----- Endpoint: snapshot.get - - /** - * Returns information about a snapshot. - * - * - */ - - public GetSnapshotResponse get(GetSnapshotRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetSnapshotRequest, - GetSnapshotResponse, - ErrorResponse>) GetSnapshotRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about a snapshot. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetSnapshotRequest} - * - */ - - public final GetSnapshotResponse get(Function> fn) throws IOException, - OpenSearchException { - return get(fn.apply(new GetSnapshotRequest.Builder()).build()); - } - // ----- Endpoint: snapshot.get_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 0236f7bdd2..84efd20cdf 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", "verify_repository")), + and(namespace("snapshot"), named("cleanup_repository", "clone", "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 0877974e78..fe492f1dbe 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.get": + return "GetSnapshot"; case "tasks.get": return "GetTasks"; default: