From f06bd54d1624b1c22808dd93bc38d59d3a50d0f7 Mon Sep 17 00:00:00 2001 From: Laura Date: Thu, 7 Mar 2024 10:57:50 +0100 Subject: [PATCH] fixes from api-spec pr 2440 --- .../elasticsearch/_types/InlineGet.java | 18 +- .../_types/mapping/DenseVectorProperty.java | 22 +- .../_types/mapping/GeoPointProperty.java | 94 +++++ .../_types/mapping/RankFeaturesProperty.java | 32 ++ .../elasticsearch/core/search/InnerHits.java | 38 +- .../elasticsearch/doc-files/api-spec.html | 151 ++++---- .../enrich/ExecutePolicyResponse.java | 20 +- .../indices/DataStreamsStatsResponse.java | 11 +- .../DataStreamsStatsItem.java | 10 +- .../elasticsearch/security/get_role/Role.java | 19 +- .../security/get_role/TransientMetadata.java | 24 +- .../snapshot/AzureRepository.java | 157 ++++++++ .../snapshot/AzureRepositorySettings.java | 264 +++++++++++++ .../snapshot/CreateRepositoryRequest.java | 149 +++----- .../elasticsearch/snapshot/GcsRepository.java | 157 ++++++++ .../snapshot/GcsRepositorySettings.java | 259 +++++++++++++ .../snapshot/ReadOnlyUrlRepository.java | 158 ++++++++ .../ReadOnlyUrlRepositorySettings.java | 238 ++++++++++++ .../elasticsearch/snapshot/Repository.java | 350 ++++++++++++++---- .../snapshot/RepositoryBase.java | 129 +++++++ .../snapshot/RepositoryBuilders.java | 155 ++++++++ .../snapshot/RepositorySettingsBase.java | 220 +++++++++++ .../snapshot/RepositoryVariant.java | 50 +++ .../elasticsearch/snapshot/S3Repository.java | 154 ++++++++ .../snapshot/S3RepositorySettings.java | 346 +++++++++++++++++ .../snapshot/SharedFileSystemRepository.java | 159 ++++++++ .../SharedFileSystemRepositorySettings.java | 205 ++++++++++ .../snapshot/SourceOnlyRepository.java | 158 ++++++++ .../SourceOnlyRepositorySettings.java | 207 +++++++++++ 29 files changed, 3631 insertions(+), 323 deletions(-) create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepository.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepositorySettings.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/GcsRepository.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/GcsRepositorySettings.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/ReadOnlyUrlRepository.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/ReadOnlyUrlRepositorySettings.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryBase.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryBuilders.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositorySettingsBase.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryVariant.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/S3Repository.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/S3RepositorySettings.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SharedFileSystemRepository.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SharedFileSystemRepositorySettings.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SourceOnlyRepository.java create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SourceOnlyRepositorySettings.java diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InlineGet.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InlineGet.java index 429f25552..61156fda3 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InlineGet.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InlineGet.java @@ -82,6 +82,7 @@ public class InlineGet implements JsonpSerializable { @Nullable private final String routing; + @Nullable private final TDocument source; @Nullable @@ -98,7 +99,7 @@ private InlineGet(Builder builder) { this.seqNo = builder.seqNo; this.primaryTerm = builder.primaryTerm; this.routing = builder.routing; - this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); + this.source = builder.source; this.tDocumentSerializer = builder.tDocumentSerializer; } @@ -154,8 +155,9 @@ public final String routing() { } /** - * Required - API name: {@code _source} + * API name: {@code _source} */ + @Nullable public final TDocument source() { return this.source; } @@ -206,8 +208,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.routing); } - generator.writeKey("_source"); - JsonpUtils.serialize(this.source, generator, tDocumentSerializer, mapper); + if (this.source != null) { + generator.writeKey("_source"); + JsonpUtils.serialize(this.source, generator, tDocumentSerializer, mapper); + + } } @@ -262,6 +267,7 @@ public final Builder metadata(String key, JsonData value) { @Nullable private String routing; + @Nullable private TDocument source; @Nullable @@ -320,9 +326,9 @@ public final Builder routing(@Nullable String value) { } /** - * Required - API name: {@code _source} + * API name: {@code _source} */ - public final Builder source(TDocument value) { + public final Builder source(@Nullable TDocument value) { this.source = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/DenseVectorProperty.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/DenseVectorProperty.java index 13ca8b819..ff85c4f63 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/DenseVectorProperty.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/DenseVectorProperty.java @@ -24,7 +24,6 @@ import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; @@ -59,7 +58,8 @@ */ @JsonpDeserializable public class DenseVectorProperty extends PropertyBase implements PropertyVariant { - private final int dims; + @Nullable + private final Integer dims; @Nullable private final String similarity; @@ -75,7 +75,7 @@ public class DenseVectorProperty extends PropertyBase implements PropertyVariant private DenseVectorProperty(Builder builder) { super(builder); - this.dims = ApiTypeHelper.requireNonNull(builder.dims, this, "dims"); + this.dims = builder.dims; this.similarity = builder.similarity; this.index = builder.index; this.indexOptions = builder.indexOptions; @@ -95,9 +95,10 @@ public Property.Kind _propertyKind() { } /** - * Required - API name: {@code dims} + * API name: {@code dims} */ - public final int dims() { + @Nullable + public final Integer dims() { return this.dims; } @@ -129,9 +130,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "dense_vector"); super.serializeInternal(generator, mapper); - generator.writeKey("dims"); - generator.write(this.dims); + if (this.dims != null) { + generator.writeKey("dims"); + generator.write(this.dims); + } if (this.similarity != null) { generator.writeKey("similarity"); generator.write(this.similarity); @@ -159,6 +162,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends PropertyBase.AbstractBuilder implements ObjectBuilder { + @Nullable private Integer dims; @Nullable @@ -171,9 +175,9 @@ public static class Builder extends PropertyBase.AbstractBuilder private DenseVectorIndexOptions indexOptions; /** - * Required - API name: {@code dims} + * API name: {@code dims} */ - public final Builder dims(int value) { + public final Builder dims(@Nullable Integer value) { this.dims = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/GeoPointProperty.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/GeoPointProperty.java index 7610ffba0..956f2e502 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/GeoPointProperty.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/GeoPointProperty.java @@ -20,6 +20,7 @@ package co.elastic.clients.elasticsearch._types.mapping; import co.elastic.clients.elasticsearch._types.GeoLocation; +import co.elastic.clients.elasticsearch._types.Script; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -66,6 +67,15 @@ public class GeoPointProperty extends DocValuesPropertyBase implements PropertyV @Nullable private final GeoLocation nullValue; + @Nullable + private final Boolean index; + + @Nullable + private final OnScriptError onScriptError; + + @Nullable + private final Script script; + // --------------------------------------------------------------------------------------------- private GeoPointProperty(Builder builder) { @@ -74,6 +84,9 @@ private GeoPointProperty(Builder builder) { this.ignoreMalformed = builder.ignoreMalformed; this.ignoreZValue = builder.ignoreZValue; this.nullValue = builder.nullValue; + this.index = builder.index; + this.onScriptError = builder.onScriptError; + this.script = builder.script; } @@ -113,6 +126,30 @@ public final GeoLocation nullValue() { return this.nullValue; } + /** + * API name: {@code index} + */ + @Nullable + public final Boolean index() { + return this.index; + } + + /** + * API name: {@code on_script_error} + */ + @Nullable + public final OnScriptError onScriptError() { + return this.onScriptError; + } + + /** + * API name: {@code script} + */ + @Nullable + public final Script script() { + return this.script; + } + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "geo_point"); @@ -132,6 +169,20 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.nullValue.serialize(generator, mapper); } + if (this.index != null) { + generator.writeKey("index"); + generator.write(this.index); + + } + if (this.onScriptError != null) { + generator.writeKey("on_script_error"); + this.onScriptError.serialize(generator, mapper); + } + if (this.script != null) { + generator.writeKey("script"); + this.script.serialize(generator, mapper); + + } } @@ -153,6 +204,15 @@ public static class Builder extends DocValuesPropertyBase.AbstractBuilder> fn) { + return this.script(fn.apply(new Script.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -215,6 +306,9 @@ protected static void setupGeoPointPropertyDeserializer(ObjectDeserializer> fn) { @@ -73,10 +80,23 @@ public Property.Kind _propertyKind() { return Property.Kind.RankFeatures; } + /** + * API name: {@code positive_score_impact} + */ + @Nullable + public final Boolean positiveScoreImpact() { + return this.positiveScoreImpact; + } + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "rank_features"); super.serializeInternal(generator, mapper); + if (this.positiveScoreImpact != null) { + generator.writeKey("positive_score_impact"); + generator.write(this.positiveScoreImpact); + + } } @@ -89,6 +109,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends PropertyBase.AbstractBuilder implements ObjectBuilder { + @Nullable + private Boolean positiveScoreImpact; + + /** + * API name: {@code positive_score_impact} + */ + public final Builder positiveScoreImpact(@Nullable Boolean value) { + this.positiveScoreImpact = value; + return this; + } + @Override protected Builder self() { return this; @@ -117,6 +148,7 @@ public RankFeaturesProperty build() { protected static void setupRankFeaturesPropertyDeserializer(ObjectDeserializer op) { PropertyBase.setupPropertyBaseDeserializer(op); + op.add(Builder::positiveScoreImpact, JsonpDeserializer.booleanDeserializer(), "positive_score_impact"); op.ignore("type"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/InnerHits.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/InnerHits.java index cb794a01a..ca29699c5 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/InnerHits.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/InnerHits.java @@ -102,7 +102,7 @@ public class InnerHits implements JsonpSerializable { @Nullable private final SourceConfig source; - private final List storedField; + private final List storedFields; @Nullable private final Boolean trackScores; @@ -127,7 +127,7 @@ private InnerHits(Builder builder) { this.fields = ApiTypeHelper.unmodifiable(builder.fields); this.sort = ApiTypeHelper.unmodifiable(builder.sort); this.source = builder.source; - this.storedField = ApiTypeHelper.unmodifiable(builder.storedField); + this.storedFields = ApiTypeHelper.unmodifiable(builder.storedFields); this.trackScores = builder.trackScores; this.version = builder.version; @@ -238,10 +238,10 @@ public final SourceConfig source() { } /** - * API name: {@code stored_field} + * API name: {@code stored_fields} */ - public final List storedField() { - return this.storedField; + public final List storedFields() { + return this.storedFields; } /** @@ -357,10 +357,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.source.serialize(generator, mapper); } - if (ApiTypeHelper.isDefined(this.storedField)) { - generator.writeKey("stored_field"); + if (ApiTypeHelper.isDefined(this.storedFields)) { + generator.writeKey("stored_fields"); generator.writeStartArray(); - for (String item0 : this.storedField) { + for (String item0 : this.storedFields) { generator.write(item0); } @@ -432,7 +432,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private SourceConfig source; @Nullable - private List storedField; + private List storedFields; @Nullable private Boolean trackScores; @@ -641,22 +641,22 @@ public final Builder source(Function - * Adds all elements of list to storedField. + * Adds all elements of list to storedFields. */ - public final Builder storedField(List list) { - this.storedField = _listAddAll(this.storedField, list); + public final Builder storedFields(List list) { + this.storedFields = _listAddAll(this.storedFields, list); return this; } /** - * API name: {@code stored_field} + * API name: {@code stored_fields} *

- * Adds one or more values to storedField. + * Adds one or more values to storedFields. */ - public final Builder storedField(String value, String... values) { - this.storedField = _listAdd(this.storedField, value, values); + public final Builder storedFields(String value, String... values) { + this.storedFields = _listAdd(this.storedFields, value, values); return this; } @@ -719,8 +719,8 @@ protected static void setupInnerHitsDeserializer(ObjectDeserializer 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/ce97fb5902942c440d83149fbc8f79f690904858/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/694f9331579bfd26e3ed9ab97100700e78c3eae7/specification/" + (paths[hash] || ""); - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/enrich/ExecutePolicyResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/enrich/ExecutePolicyResponse.java index 92a390c65..f489217df 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/enrich/ExecutePolicyResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/enrich/ExecutePolicyResponse.java @@ -27,7 +27,6 @@ import co.elastic.clients.json.JsonpUtils; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; @@ -60,6 +59,7 @@ */ @JsonpDeserializable public class ExecutePolicyResponse implements JsonpSerializable { + @Nullable private final ExecuteEnrichPolicyStatus status; @Nullable @@ -69,7 +69,7 @@ public class ExecutePolicyResponse implements JsonpSerializable { private ExecutePolicyResponse(Builder builder) { - this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); + this.status = builder.status; this.taskId = builder.taskId; } @@ -79,8 +79,9 @@ public static ExecutePolicyResponse of(Function implements ObjectBuilder { + @Nullable private ExecuteEnrichPolicyStatus status; @Nullable private String taskId; /** - * Required - API name: {@code status} + * API name: {@code status} */ - public final Builder status(ExecuteEnrichPolicyStatus value) { + public final Builder status(@Nullable ExecuteEnrichPolicyStatus value) { this.status = value; return this; } /** - * Required - API name: {@code status} + * API name: {@code status} */ public final Builder status( Function> fn) { diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/DataStreamsStatsResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/DataStreamsStatsResponse.java index a07717899..02769f5ce 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/DataStreamsStatsResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/DataStreamsStatsResponse.java @@ -33,6 +33,7 @@ import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; import java.lang.Integer; +import java.lang.Long; import java.lang.String; import java.util.List; import java.util.Objects; @@ -73,7 +74,7 @@ public class DataStreamsStatsResponse implements JsonpSerializable { @Nullable private final String totalStoreSizes; - private final int totalStoreSizeBytes; + private final long totalStoreSizeBytes; private final List dataStreams; @@ -127,7 +128,7 @@ public final String totalStoreSizes() { /** * Required - API name: {@code total_store_size_bytes} */ - public final int totalStoreSizeBytes() { + public final long totalStoreSizeBytes() { return this.totalStoreSizeBytes; } @@ -202,7 +203,7 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private String totalStoreSizes; - private Integer totalStoreSizeBytes; + private Long totalStoreSizeBytes; private List dataStreams; @@ -248,7 +249,7 @@ public final Builder totalStoreSizes(@Nullable String value) { /** * Required - API name: {@code total_store_size_bytes} */ - public final Builder totalStoreSizeBytes(int value) { + public final Builder totalStoreSizeBytes(long value) { this.totalStoreSizeBytes = value; return this; } @@ -316,7 +317,7 @@ protected static void setupDataStreamsStatsResponseDeserializer( op.add(Builder::backingIndices, JsonpDeserializer.integerDeserializer(), "backing_indices"); op.add(Builder::dataStreamCount, JsonpDeserializer.integerDeserializer(), "data_stream_count"); op.add(Builder::totalStoreSizes, JsonpDeserializer.stringDeserializer(), "total_store_sizes"); - op.add(Builder::totalStoreSizeBytes, JsonpDeserializer.integerDeserializer(), "total_store_size_bytes"); + op.add(Builder::totalStoreSizeBytes, JsonpDeserializer.longDeserializer(), "total_store_size_bytes"); op.add(Builder::dataStreams, JsonpDeserializer.arrayDeserializer(DataStreamsStatsItem._DESERIALIZER), "data_streams"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/data_streams_stats/DataStreamsStatsItem.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/data_streams_stats/DataStreamsStatsItem.java index c78748e3c..4ebec7d42 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/data_streams_stats/DataStreamsStatsItem.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/data_streams_stats/DataStreamsStatsItem.java @@ -69,7 +69,7 @@ public class DataStreamsStatsItem implements JsonpSerializable { @Nullable private final String storeSize; - private final int storeSizeBytes; + private final long storeSizeBytes; private final long maximumTimestamp; @@ -114,7 +114,7 @@ public final String storeSize() { /** * Required - API name: {@code store_size_bytes} */ - public final int storeSizeBytes() { + public final long storeSizeBytes() { return this.storeSizeBytes; } @@ -176,7 +176,7 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private String storeSize; - private Integer storeSizeBytes; + private Long storeSizeBytes; private Long maximumTimestamp; @@ -207,7 +207,7 @@ public final Builder storeSize(@Nullable String value) { /** * Required - API name: {@code store_size_bytes} */ - public final Builder storeSizeBytes(int value) { + public final Builder storeSizeBytes(long value) { this.storeSizeBytes = value; return this; } @@ -251,7 +251,7 @@ protected static void setupDataStreamsStatsItemDeserializer(ObjectDeserializer runAs; + @Nullable private final TransientMetadata transientMetadata; private final List applications; @@ -87,7 +88,7 @@ private Role(Builder builder) { this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); this.metadata = ApiTypeHelper.unmodifiableRequired(builder.metadata, this, "metadata"); this.runAs = ApiTypeHelper.unmodifiableRequired(builder.runAs, this, "runAs"); - this.transientMetadata = ApiTypeHelper.requireNonNull(builder.transientMetadata, this, "transientMetadata"); + this.transientMetadata = builder.transientMetadata; this.applications = ApiTypeHelper.unmodifiableRequired(builder.applications, this, "applications"); this.roleTemplates = ApiTypeHelper.unmodifiable(builder.roleTemplates); @@ -126,8 +127,9 @@ public final List runAs() { } /** - * Required - API name: {@code transient_metadata} + * API name: {@code transient_metadata} */ + @Nullable public final TransientMetadata transientMetadata() { return this.transientMetadata; } @@ -198,9 +200,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } - generator.writeKey("transient_metadata"); - this.transientMetadata.serialize(generator, mapper); + if (this.transientMetadata != null) { + generator.writeKey("transient_metadata"); + this.transientMetadata.serialize(generator, mapper); + } if (ApiTypeHelper.isDefined(this.applications)) { generator.writeKey("applications"); generator.writeStartArray(); @@ -244,6 +248,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private List runAs; + @Nullable private TransientMetadata transientMetadata; private List applications; @@ -341,15 +346,15 @@ public final Builder runAs(String value, String... values) { } /** - * Required - API name: {@code transient_metadata} + * API name: {@code transient_metadata} */ - public final Builder transientMetadata(TransientMetadata value) { + public final Builder transientMetadata(@Nullable TransientMetadata value) { this.transientMetadata = value; return this; } /** - * Required - API name: {@code transient_metadata} + * API name: {@code transient_metadata} */ public final Builder transientMetadata( Function> fn) { diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_role/TransientMetadata.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_role/TransientMetadata.java index 588da69d8..217ad5fc2 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_role/TransientMetadata.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/get_role/TransientMetadata.java @@ -26,13 +26,13 @@ import co.elastic.clients.json.JsonpUtils; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; import java.util.Objects; import java.util.function.Function; +import javax.annotation.Nullable; //---------------------------------------------------------------- // THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. @@ -59,13 +59,14 @@ */ @JsonpDeserializable public class TransientMetadata implements JsonpSerializable { - private final boolean enabled; + @Nullable + private final Boolean enabled; // --------------------------------------------------------------------------------------------- private TransientMetadata(Builder builder) { - this.enabled = ApiTypeHelper.requireNonNull(builder.enabled, this, "enabled"); + this.enabled = builder.enabled; } @@ -74,9 +75,10 @@ public static TransientMetadata of(Function implements ObjectBuilder { + @Nullable private Boolean enabled; /** - * Required - API name: {@code enabled} + * API name: {@code enabled} */ - public final Builder enabled(boolean value) { + public final Builder enabled(@Nullable Boolean value) { this.enabled = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepository.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepository.java new file mode 100644 index 000000000..68943221d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepository.java @@ -0,0 +1,157 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.AzureRepository + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class AzureRepository extends RepositoryBase implements RepositoryVariant { + private final AzureRepositorySettings settings; + + // --------------------------------------------------------------------------------------------- + + private AzureRepository(Builder builder) { + super(builder); + + this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); + + } + + public static AzureRepository of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Repository variant kind. + */ + @Override + public Repository.Kind _repositoryKind() { + return Repository.Kind.Azure; + } + + /** + * Required - API name: {@code settings} + */ + public final AzureRepositorySettings settings() { + return this.settings; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "azure"); + super.serializeInternal(generator, mapper); + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link AzureRepository}. + */ + + public static class Builder extends RepositoryBase.AbstractBuilder + implements + ObjectBuilder { + private AzureRepositorySettings settings; + + /** + * Required - API name: {@code settings} + */ + public final Builder settings(AzureRepositorySettings value) { + this.settings = value; + return this; + } + + /** + * Required - API name: {@code settings} + */ + public final Builder settings( + Function> fn) { + return this.settings(fn.apply(new AzureRepositorySettings.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link AzureRepository}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public AzureRepository build() { + _checkSingleUse(); + + return new AzureRepository(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link AzureRepository} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + AzureRepository::setupAzureRepositoryDeserializer); + + protected static void setupAzureRepositoryDeserializer(ObjectDeserializer op) { + RepositoryBase.setupRepositoryBaseDeserializer(op); + op.add(Builder::settings, AzureRepositorySettings._DESERIALIZER, "settings"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepositorySettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepositorySettings.java new file mode 100644 index 000000000..81d342bd2 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/AzureRepositorySettings.java @@ -0,0 +1,264 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.AzureRepositorySettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class AzureRepositorySettings extends RepositorySettingsBase { + @Nullable + private final String client; + + @Nullable + private final String container; + + @Nullable + private final String basePath; + + @Nullable + private final Boolean readonly; + + @Nullable + private final String locationMode; + + // --------------------------------------------------------------------------------------------- + + private AzureRepositorySettings(Builder builder) { + super(builder); + + this.client = builder.client; + this.container = builder.container; + this.basePath = builder.basePath; + this.readonly = builder.readonly; + this.locationMode = builder.locationMode; + + } + + public static AzureRepositorySettings of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code client} + */ + @Nullable + public final String client() { + return this.client; + } + + /** + * API name: {@code container} + */ + @Nullable + public final String container() { + return this.container; + } + + /** + * API name: {@code base_path} + */ + @Nullable + public final String basePath() { + return this.basePath; + } + + /** + * API name: {@code readonly} + */ + @Nullable + public final Boolean readonly() { + return this.readonly; + } + + /** + * API name: {@code location_mode} + */ + @Nullable + public final String locationMode() { + return this.locationMode; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + if (this.client != null) { + generator.writeKey("client"); + generator.write(this.client); + + } + if (this.container != null) { + generator.writeKey("container"); + generator.write(this.container); + + } + if (this.basePath != null) { + generator.writeKey("base_path"); + generator.write(this.basePath); + + } + if (this.readonly != null) { + generator.writeKey("readonly"); + generator.write(this.readonly); + + } + if (this.locationMode != null) { + generator.writeKey("location_mode"); + generator.write(this.locationMode); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link AzureRepositorySettings}. + */ + + public static class Builder extends RepositorySettingsBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private String client; + + @Nullable + private String container; + + @Nullable + private String basePath; + + @Nullable + private Boolean readonly; + + @Nullable + private String locationMode; + + /** + * API name: {@code client} + */ + public final Builder client(@Nullable String value) { + this.client = value; + return this; + } + + /** + * API name: {@code container} + */ + public final Builder container(@Nullable String value) { + this.container = value; + return this; + } + + /** + * API name: {@code base_path} + */ + public final Builder basePath(@Nullable String value) { + this.basePath = value; + return this; + } + + /** + * API name: {@code readonly} + */ + public final Builder readonly(@Nullable Boolean value) { + this.readonly = value; + return this; + } + + /** + * API name: {@code location_mode} + */ + public final Builder locationMode(@Nullable String value) { + this.locationMode = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link AzureRepositorySettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public AzureRepositorySettings build() { + _checkSingleUse(); + + return new AzureRepositorySettings(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link AzureRepositorySettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, AzureRepositorySettings::setupAzureRepositorySettingsDeserializer); + + protected static void setupAzureRepositorySettingsDeserializer( + ObjectDeserializer op) { + RepositorySettingsBase.setupRepositorySettingsBaseDeserializer(op); + op.add(Builder::client, JsonpDeserializer.stringDeserializer(), "client"); + op.add(Builder::container, JsonpDeserializer.stringDeserializer(), "container"); + op.add(Builder::basePath, JsonpDeserializer.stringDeserializer(), "base_path"); + op.add(Builder::readonly, JsonpDeserializer.booleanDeserializer(), "readonly"); + op.add(Builder::locationMode, JsonpDeserializer.stringDeserializer(), "location_mode"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/CreateRepositoryRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/CreateRepositoryRequest.java index e01696289..05faf475d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/CreateRepositoryRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/CreateRepositoryRequest.java @@ -33,6 +33,7 @@ import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; +import jakarta.json.stream.JsonParser; import java.lang.Boolean; import java.lang.String; import java.util.HashMap; @@ -72,30 +73,23 @@ public class CreateRepositoryRequest extends RequestBase implements JsonpSeriali private final String name; - @Nullable - private final Repository repository; - - private final RepositorySettings settings; - @Nullable private final Time timeout; - private final String type; - @Nullable private final Boolean verify; + private final Repository repository; + // --------------------------------------------------------------------------------------------- private CreateRepositoryRequest(Builder builder) { this.masterTimeout = builder.masterTimeout; this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); - this.repository = builder.repository; - this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); this.timeout = builder.timeout; - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); this.verify = builder.verify; + this.repository = ApiTypeHelper.requireNonNull(builder.repository, this, "repository"); } @@ -122,21 +116,6 @@ public final String name() { return this.name; } - /** - * API name: {@code repository} - */ - @Nullable - public final Repository repository() { - return this.repository; - } - - /** - * Required - API name: {@code settings} - */ - public final RepositorySettings settings() { - return this.settings; - } - /** * Explicit operation timeout *

@@ -147,13 +126,6 @@ public final Time timeout() { return this.timeout; } - /** - * Required - API name: {@code type} - */ - public final String type() { - return this.type; - } - /** * Whether to verify the repository after creation *

@@ -165,26 +137,17 @@ public final Boolean verify() { } /** - * Serialize this object to JSON. + * Required - Request body. */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); + public final Repository repository() { + return this.repository; } - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (this.repository != null) { - generator.writeKey("repository"); - this.repository.serialize(generator, mapper); - - } - generator.writeKey("settings"); - this.settings.serialize(generator, mapper); - - generator.writeKey("type"); - generator.write(this.type); + /** + * Serialize this value to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + this.repository.serialize(generator, mapper); } @@ -202,19 +165,14 @@ public static class Builder extends RequestBase.AbstractBuilder private String name; - @Nullable - private Repository repository; - - private RepositorySettings settings; - @Nullable private Time timeout; - private String type; - @Nullable private Boolean verify; + private Repository repository; + /** * Explicit operation timeout for connection to master node *

@@ -244,36 +202,6 @@ public final Builder name(String value) { return this; } - /** - * API name: {@code repository} - */ - public final Builder repository(@Nullable Repository value) { - this.repository = value; - return this; - } - - /** - * API name: {@code repository} - */ - public final Builder repository(Function> fn) { - return this.repository(fn.apply(new Repository.Builder()).build()); - } - - /** - * Required - API name: {@code settings} - */ - public final Builder settings(RepositorySettings value) { - this.settings = value; - return this; - } - - /** - * Required - API name: {@code settings} - */ - public final Builder settings(Function> fn) { - return this.settings(fn.apply(new RepositorySettings.Builder()).build()); - } - /** * Explicit operation timeout *

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

@@ -311,6 +231,29 @@ public final Builder verify(@Nullable Boolean value) { return this; } + /** + * Required - Request body. + */ + public final Builder repository(Repository value) { + this.repository = value; + return this; + } + + /** + * Required - Request body. + */ + public final Builder repository(Function> fn) { + return this.repository(fn.apply(new Repository.Builder()).build()); + } + + @Override + public Builder withJson(JsonParser parser, JsonpMapper mapper) { + + @SuppressWarnings("unchecked") + Repository value = (Repository) Repository._DESERIALIZER.deserialize(parser, mapper); + return this.repository(value); + } + @Override protected Builder self() { return this; @@ -329,21 +272,13 @@ public CreateRepositoryRequest build() { } } - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link CreateRepositoryRequest} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, CreateRepositoryRequest::setupCreateRepositoryRequestDeserializer); - - protected static void setupCreateRepositoryRequestDeserializer( - ObjectDeserializer op) { + public static final JsonpDeserializer _DESERIALIZER = createCreateRepositoryRequestDeserializer(); + protected static JsonpDeserializer createCreateRepositoryRequestDeserializer() { - op.add(Builder::repository, Repository._DESERIALIZER, "repository"); - op.add(Builder::settings, RepositorySettings._DESERIALIZER, "settings"); - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + JsonpDeserializer valueDeserializer = Repository._DESERIALIZER; + return JsonpDeserializer.of(valueDeserializer.acceptedEvents(), (parser, mapper, event) -> new Builder() + .repository(valueDeserializer.deserialize(parser, mapper, event)).build()); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/GcsRepository.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/GcsRepository.java new file mode 100644 index 000000000..786d6a220 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/GcsRepository.java @@ -0,0 +1,157 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.GcsRepository + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class GcsRepository extends RepositoryBase implements RepositoryVariant { + private final GcsRepositorySettings settings; + + // --------------------------------------------------------------------------------------------- + + private GcsRepository(Builder builder) { + super(builder); + + this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); + + } + + public static GcsRepository of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Repository variant kind. + */ + @Override + public Repository.Kind _repositoryKind() { + return Repository.Kind.Gcs; + } + + /** + * Required - API name: {@code settings} + */ + public final GcsRepositorySettings settings() { + return this.settings; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "gcs"); + super.serializeInternal(generator, mapper); + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GcsRepository}. + */ + + public static class Builder extends RepositoryBase.AbstractBuilder + implements + ObjectBuilder { + private GcsRepositorySettings settings; + + /** + * Required - API name: {@code settings} + */ + public final Builder settings(GcsRepositorySettings value) { + this.settings = value; + return this; + } + + /** + * Required - API name: {@code settings} + */ + public final Builder settings( + Function> fn) { + return this.settings(fn.apply(new GcsRepositorySettings.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GcsRepository}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GcsRepository build() { + _checkSingleUse(); + + return new GcsRepository(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GcsRepository} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + GcsRepository::setupGcsRepositoryDeserializer); + + protected static void setupGcsRepositoryDeserializer(ObjectDeserializer op) { + RepositoryBase.setupRepositoryBaseDeserializer(op); + op.add(Builder::settings, GcsRepositorySettings._DESERIALIZER, "settings"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/GcsRepositorySettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/GcsRepositorySettings.java new file mode 100644 index 000000000..3bf19af9d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/GcsRepositorySettings.java @@ -0,0 +1,259 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.GcsRepositorySettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class GcsRepositorySettings extends RepositorySettingsBase { + private final String bucket; + + @Nullable + private final String client; + + @Nullable + private final String basePath; + + @Nullable + private final Boolean readonly; + + @Nullable + private final String applicationName; + + // --------------------------------------------------------------------------------------------- + + private GcsRepositorySettings(Builder builder) { + super(builder); + + this.bucket = ApiTypeHelper.requireNonNull(builder.bucket, this, "bucket"); + this.client = builder.client; + this.basePath = builder.basePath; + this.readonly = builder.readonly; + this.applicationName = builder.applicationName; + + } + + public static GcsRepositorySettings of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code bucket} + */ + public final String bucket() { + return this.bucket; + } + + /** + * API name: {@code client} + */ + @Nullable + public final String client() { + return this.client; + } + + /** + * API name: {@code base_path} + */ + @Nullable + public final String basePath() { + return this.basePath; + } + + /** + * API name: {@code readonly} + */ + @Nullable + public final Boolean readonly() { + return this.readonly; + } + + /** + * API name: {@code application_name} + */ + @Nullable + public final String applicationName() { + return this.applicationName; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + generator.writeKey("bucket"); + generator.write(this.bucket); + + if (this.client != null) { + generator.writeKey("client"); + generator.write(this.client); + + } + if (this.basePath != null) { + generator.writeKey("base_path"); + generator.write(this.basePath); + + } + if (this.readonly != null) { + generator.writeKey("readonly"); + generator.write(this.readonly); + + } + if (this.applicationName != null) { + generator.writeKey("application_name"); + generator.write(this.applicationName); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GcsRepositorySettings}. + */ + + public static class Builder extends RepositorySettingsBase.AbstractBuilder + implements + ObjectBuilder { + private String bucket; + + @Nullable + private String client; + + @Nullable + private String basePath; + + @Nullable + private Boolean readonly; + + @Nullable + private String applicationName; + + /** + * Required - API name: {@code bucket} + */ + public final Builder bucket(String value) { + this.bucket = value; + return this; + } + + /** + * API name: {@code client} + */ + public final Builder client(@Nullable String value) { + this.client = value; + return this; + } + + /** + * API name: {@code base_path} + */ + public final Builder basePath(@Nullable String value) { + this.basePath = value; + return this; + } + + /** + * API name: {@code readonly} + */ + public final Builder readonly(@Nullable Boolean value) { + this.readonly = value; + return this; + } + + /** + * API name: {@code application_name} + */ + public final Builder applicationName(@Nullable String value) { + this.applicationName = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link GcsRepositorySettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GcsRepositorySettings build() { + _checkSingleUse(); + + return new GcsRepositorySettings(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GcsRepositorySettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, GcsRepositorySettings::setupGcsRepositorySettingsDeserializer); + + protected static void setupGcsRepositorySettingsDeserializer(ObjectDeserializer op) { + RepositorySettingsBase.setupRepositorySettingsBaseDeserializer(op); + op.add(Builder::bucket, JsonpDeserializer.stringDeserializer(), "bucket"); + op.add(Builder::client, JsonpDeserializer.stringDeserializer(), "client"); + op.add(Builder::basePath, JsonpDeserializer.stringDeserializer(), "base_path"); + op.add(Builder::readonly, JsonpDeserializer.booleanDeserializer(), "readonly"); + op.add(Builder::applicationName, JsonpDeserializer.stringDeserializer(), "application_name"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/ReadOnlyUrlRepository.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/ReadOnlyUrlRepository.java new file mode 100644 index 000000000..000230998 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/ReadOnlyUrlRepository.java @@ -0,0 +1,158 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.ReadOnlyUrlRepository + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ReadOnlyUrlRepository extends RepositoryBase implements RepositoryVariant { + private final ReadOnlyUrlRepositorySettings settings; + + // --------------------------------------------------------------------------------------------- + + private ReadOnlyUrlRepository(Builder builder) { + super(builder); + + this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); + + } + + public static ReadOnlyUrlRepository of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Repository variant kind. + */ + @Override + public Repository.Kind _repositoryKind() { + return Repository.Kind.Url; + } + + /** + * Required - API name: {@code settings} + */ + public final ReadOnlyUrlRepositorySettings settings() { + return this.settings; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "url"); + super.serializeInternal(generator, mapper); + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ReadOnlyUrlRepository}. + */ + + public static class Builder extends RepositoryBase.AbstractBuilder + implements + ObjectBuilder { + private ReadOnlyUrlRepositorySettings settings; + + /** + * Required - API name: {@code settings} + */ + public final Builder settings(ReadOnlyUrlRepositorySettings value) { + this.settings = value; + return this; + } + + /** + * Required - API name: {@code settings} + */ + public final Builder settings( + Function> fn) { + return this.settings(fn.apply(new ReadOnlyUrlRepositorySettings.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ReadOnlyUrlRepository}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ReadOnlyUrlRepository build() { + _checkSingleUse(); + + return new ReadOnlyUrlRepository(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ReadOnlyUrlRepository} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ReadOnlyUrlRepository::setupReadOnlyUrlRepositoryDeserializer); + + protected static void setupReadOnlyUrlRepositoryDeserializer(ObjectDeserializer op) { + RepositoryBase.setupRepositoryBaseDeserializer(op); + op.add(Builder::settings, ReadOnlyUrlRepositorySettings._DESERIALIZER, "settings"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/ReadOnlyUrlRepositorySettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/ReadOnlyUrlRepositorySettings.java new file mode 100644 index 000000000..1383a93af --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/ReadOnlyUrlRepositorySettings.java @@ -0,0 +1,238 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.elasticsearch._types.Time; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Integer; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.ReadOnlyUrlRepositorySettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class ReadOnlyUrlRepositorySettings extends RepositorySettingsBase { + @Nullable + private final Integer httpMaxRetries; + + @Nullable + private final Time httpSocketTimeout; + + @Nullable + private final Integer maxNumberOfSnapshots; + + private final String url; + + // --------------------------------------------------------------------------------------------- + + private ReadOnlyUrlRepositorySettings(Builder builder) { + super(builder); + + this.httpMaxRetries = builder.httpMaxRetries; + this.httpSocketTimeout = builder.httpSocketTimeout; + this.maxNumberOfSnapshots = builder.maxNumberOfSnapshots; + this.url = ApiTypeHelper.requireNonNull(builder.url, this, "url"); + + } + + public static ReadOnlyUrlRepositorySettings of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code http_max_retries} + */ + @Nullable + public final Integer httpMaxRetries() { + return this.httpMaxRetries; + } + + /** + * API name: {@code http_socket_timeout} + */ + @Nullable + public final Time httpSocketTimeout() { + return this.httpSocketTimeout; + } + + /** + * API name: {@code max_number_of_snapshots} + */ + @Nullable + public final Integer maxNumberOfSnapshots() { + return this.maxNumberOfSnapshots; + } + + /** + * Required - API name: {@code url} + */ + public final String url() { + return this.url; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + if (this.httpMaxRetries != null) { + generator.writeKey("http_max_retries"); + generator.write(this.httpMaxRetries); + + } + if (this.httpSocketTimeout != null) { + generator.writeKey("http_socket_timeout"); + this.httpSocketTimeout.serialize(generator, mapper); + + } + if (this.maxNumberOfSnapshots != null) { + generator.writeKey("max_number_of_snapshots"); + generator.write(this.maxNumberOfSnapshots); + + } + generator.writeKey("url"); + generator.write(this.url); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ReadOnlyUrlRepositorySettings}. + */ + + public static class Builder extends RepositorySettingsBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private Integer httpMaxRetries; + + @Nullable + private Time httpSocketTimeout; + + @Nullable + private Integer maxNumberOfSnapshots; + + private String url; + + /** + * API name: {@code http_max_retries} + */ + public final Builder httpMaxRetries(@Nullable Integer value) { + this.httpMaxRetries = value; + return this; + } + + /** + * API name: {@code http_socket_timeout} + */ + public final Builder httpSocketTimeout(@Nullable Time value) { + this.httpSocketTimeout = value; + return this; + } + + /** + * API name: {@code http_socket_timeout} + */ + public final Builder httpSocketTimeout(Function> fn) { + return this.httpSocketTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * API name: {@code max_number_of_snapshots} + */ + public final Builder maxNumberOfSnapshots(@Nullable Integer value) { + this.maxNumberOfSnapshots = value; + return this; + } + + /** + * Required - API name: {@code url} + */ + public final Builder url(String value) { + this.url = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ReadOnlyUrlRepositorySettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ReadOnlyUrlRepositorySettings build() { + _checkSingleUse(); + + return new ReadOnlyUrlRepositorySettings(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ReadOnlyUrlRepositorySettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, ReadOnlyUrlRepositorySettings::setupReadOnlyUrlRepositorySettingsDeserializer); + + protected static void setupReadOnlyUrlRepositorySettingsDeserializer( + ObjectDeserializer op) { + RepositorySettingsBase.setupRepositorySettingsBaseDeserializer(op); + op.add(Builder::httpMaxRetries, JsonpDeserializer.integerDeserializer(), "http_max_retries"); + op.add(Builder::httpSocketTimeout, Time._DESERIALIZER, "http_socket_timeout"); + op.add(Builder::maxNumberOfSnapshots, JsonpDeserializer.integerDeserializer(), "max_number_of_snapshots"); + op.add(Builder::url, JsonpDeserializer.stringDeserializer(), "url"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/Repository.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/Repository.java index 30f5fcf32..466cc939f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/Repository.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/Repository.java @@ -19,6 +19,8 @@ package co.elastic.clients.elasticsearch.snapshot; +import co.elastic.clients.json.JsonData; +import co.elastic.clients.json.JsonEnum; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -28,9 +30,11 @@ import co.elastic.clients.json.ObjectDeserializer; import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.OpenTaggedUnion; +import co.elastic.clients.util.TaggedUnionUtils; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; -import java.lang.String; +import java.lang.Object; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -58,21 +62,71 @@ * specification */ @JsonpDeserializable -public class Repository implements JsonpSerializable { - private final String type; +public class Repository implements OpenTaggedUnion, JsonpSerializable { - @Nullable - private final String uuid; + /** + * {@link Repository} variant kinds. + * + * @see API + * specification + */ + + public enum Kind implements JsonEnum { + Azure("azure"), + + Gcs("gcs"), + + Url("url"), + + S3("s3"), + + Fs("fs"), + + Source("source"), + + /** A custom {@code Repository} defined by a plugin */ + _Custom(null) + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final Object _value; - private final RepositorySettings settings; + @Override + public final Kind _kind() { + return _kind; + } - // --------------------------------------------------------------------------------------------- + @Override + public final Object _get() { + return _value; + } + + public Repository(RepositoryVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._repositoryKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + this._customKind = null; + + } private Repository(Builder builder) { - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - this.uuid = builder.uuid; - this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + this._customKind = builder._customKind; } @@ -81,133 +135,271 @@ public static Repository of(Function> fn) { } /** - * Required - API name: {@code type} + * Build a custom plugin-defined {@code Repository}, given its kind and some + * JSON data */ - public final String type() { - return this.type; + public Repository(String kind, JsonData value) { + this._kind = Kind._Custom; + this._value = value; + this._customKind = kind; } /** - * API name: {@code uuid} + * Is this variant instance of kind {@code azure}? */ - @Nullable - public final String uuid() { - return this.uuid; + public boolean isAzure() { + return _kind == Kind.Azure; } /** - * Required - API name: {@code settings} + * Get the {@code azure} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code azure} kind. */ - public final RepositorySettings settings() { - return this.settings; + public AzureRepository azure() { + return TaggedUnionUtils.get(this, Kind.Azure); } /** - * Serialize this object to JSON. + * Is this variant instance of kind {@code gcs}? */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); + public boolean isGcs() { + return _kind == Kind.Gcs; + } + + /** + * Get the {@code gcs} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code gcs} kind. + */ + public GcsRepository gcs() { + return TaggedUnionUtils.get(this, Kind.Gcs); } - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + /** + * Is this variant instance of kind {@code url}? + */ + public boolean isUrl() { + return _kind == Kind.Url; + } - generator.writeKey("type"); - generator.write(this.type); + /** + * Get the {@code url} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code url} kind. + */ + public ReadOnlyUrlRepository url() { + return TaggedUnionUtils.get(this, Kind.Url); + } - if (this.uuid != null) { - generator.writeKey("uuid"); - generator.write(this.uuid); + /** + * Is this variant instance of kind {@code s3}? + */ + public boolean isS3() { + return _kind == Kind.S3; + } - } - generator.writeKey("settings"); - this.settings.serialize(generator, mapper); + /** + * Get the {@code s3} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code s3} kind. + */ + public S3Repository s3() { + return TaggedUnionUtils.get(this, Kind.S3); + } + /** + * Is this variant instance of kind {@code fs}? + */ + public boolean isFs() { + return _kind == Kind.Fs; } - @Override - public String toString() { - return JsonpUtils.toString(this); + /** + * Get the {@code fs} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code fs} kind. + */ + public SharedFileSystemRepository fs() { + return TaggedUnionUtils.get(this, Kind.Fs); + } + + /** + * Is this variant instance of kind {@code source}? + */ + public boolean isSource() { + return _kind == Kind.Source; + } + + /** + * Get the {@code source} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code source} kind. + */ + public SourceOnlyRepository source() { + return TaggedUnionUtils.get(this, Kind.Source); } - // --------------------------------------------------------------------------------------------- + @Nullable + private final String _customKind; + + /** + * Is this a custom {@code Repository} defined by a plugin? + */ + public boolean _isCustom() { + return _kind == Kind._Custom; + } /** - * Builder for {@link Repository}. + * Get the actual kind when {@code _kind()} equals {@link Kind#_Custom} + * (plugin-defined variant). */ + @Nullable + public final String _customKind() { + return _customKind; + } + + /** + * Get the custom plugin-defined variant value. + * + * @throws IllegalStateException + * if the current variant is not {@link Kind#_Custom}. + */ + public JsonData _custom() { + return TaggedUnionUtils.get(this, Kind._Custom); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + + mapper.serialize(_value, generator); + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { - private String type; + private Kind _kind; + private Object _value; + private String _customKind; + + @Override + protected Builder self() { + return this; + } + public ObjectBuilder azure(AzureRepository v) { + this._kind = Kind.Azure; + this._value = v; + return this; + } - @Nullable - private String uuid; + public ObjectBuilder azure(Function> fn) { + return this.azure(fn.apply(new AzureRepository.Builder()).build()); + } - private RepositorySettings settings; + public ObjectBuilder gcs(GcsRepository v) { + this._kind = Kind.Gcs; + this._value = v; + return this; + } - /** - * Required - API name: {@code type} - */ - public final Builder type(String value) { - this.type = value; + public ObjectBuilder gcs(Function> fn) { + return this.gcs(fn.apply(new GcsRepository.Builder()).build()); + } + + public ObjectBuilder url(ReadOnlyUrlRepository v) { + this._kind = Kind.Url; + this._value = v; return this; } - /** - * API name: {@code uuid} - */ - public final Builder uuid(@Nullable String value) { - this.uuid = value; + public ObjectBuilder url( + Function> fn) { + return this.url(fn.apply(new ReadOnlyUrlRepository.Builder()).build()); + } + + public ObjectBuilder s3(S3Repository v) { + this._kind = Kind.S3; + this._value = v; return this; } - /** - * Required - API name: {@code settings} - */ - public final Builder settings(RepositorySettings value) { - this.settings = value; + public ObjectBuilder s3(Function> fn) { + return this.s3(fn.apply(new S3Repository.Builder()).build()); + } + + public ObjectBuilder fs(SharedFileSystemRepository v) { + this._kind = Kind.Fs; + this._value = v; return this; } - /** - * Required - API name: {@code settings} - */ - public final Builder settings(Function> fn) { - return this.settings(fn.apply(new RepositorySettings.Builder()).build()); + public ObjectBuilder fs( + Function> fn) { + return this.fs(fn.apply(new SharedFileSystemRepository.Builder()).build()); } - @Override - protected Builder self() { + public ObjectBuilder source(SourceOnlyRepository v) { + this._kind = Kind.Source; + this._value = v; return this; } + public ObjectBuilder source( + Function> fn) { + return this.source(fn.apply(new SourceOnlyRepository.Builder()).build()); + } + /** - * Builds a {@link Repository}. + * Define this {@code Repository} as a plugin-defined variant. * - * @throws NullPointerException - * if some of the required fields are null. + * @param name + * the plugin-defined identifier + * @param data + * the data for this custom {@code Repository}. It is converted + * internally to {@link JsonData}. */ + public ObjectBuilder _custom(String name, Object data) { + this._kind = Kind._Custom; + this._customKind = name; + this._value = JsonData.of(data); + return this; + } + public Repository build() { _checkSingleUse(); - return new Repository(this); } + } - // --------------------------------------------------------------------------------------------- + protected static void setupRepositoryDeserializer(ObjectDeserializer op) { - /** - * Json deserializer for {@link Repository} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - Repository::setupRepositoryDeserializer); + op.add(Builder::azure, AzureRepository._DESERIALIZER, "azure"); + op.add(Builder::gcs, GcsRepository._DESERIALIZER, "gcs"); + op.add(Builder::url, ReadOnlyUrlRepository._DESERIALIZER, "url"); + op.add(Builder::s3, S3Repository._DESERIALIZER, "s3"); + op.add(Builder::fs, SharedFileSystemRepository._DESERIALIZER, "fs"); + op.add(Builder::source, SourceOnlyRepository._DESERIALIZER, "source"); - protected static void setupRepositoryDeserializer(ObjectDeserializer op) { + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + JsonpUtils.ensureCustomVariantsAllowed(parser, mapper); + builder._custom(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - op.add(Builder::uuid, JsonpDeserializer.stringDeserializer(), "uuid"); - op.add(Builder::settings, RepositorySettings._DESERIALIZER, "settings"); + op.setTypeProperty("type", null); } + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + Repository::setupRepositoryDeserializer, Builder::build); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryBase.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryBase.java new file mode 100644 index 000000000..e1d203b85 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryBase.java @@ -0,0 +1,129 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.JsonpSerializable; +import co.elastic.clients.json.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.Objects; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.RepositoryBase + +/** + * + * @see API + * specification + */ + +public abstract class RepositoryBase implements JsonpSerializable { + @Nullable + private final String uuid; + + // --------------------------------------------------------------------------------------------- + + protected RepositoryBase(AbstractBuilder builder) { + + this.uuid = builder.uuid; + + } + + /** + * API name: {@code uuid} + */ + @Nullable + public final String uuid() { + return this.uuid; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.uuid != null) { + generator.writeKey("uuid"); + generator.write(this.uuid); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + @Nullable + private String uuid; + + /** + * API name: {@code uuid} + */ + public final BuilderT uuid(@Nullable String value) { + this.uuid = value; + return self(); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupRepositoryBaseDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::uuid, JsonpDeserializer.stringDeserializer(), "uuid"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryBuilders.java new file mode 100644 index 000000000..fc37c5046 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryBuilders.java @@ -0,0 +1,155 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.util.ObjectBuilder; +import java.util.function.Function; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +/** + * Builders for {@link Repository} variants. + */ +public class RepositoryBuilders { + private RepositoryBuilders() { + } + + /** + * Creates a builder for the {@link AzureRepository azure} {@code Repository} + * variant. + */ + public static AzureRepository.Builder azure() { + return new AzureRepository.Builder(); + } + + /** + * Creates a Repository of the {@link AzureRepository azure} {@code Repository} + * variant. + */ + public static Repository azure(Function> fn) { + Repository.Builder builder = new Repository.Builder(); + builder.azure(fn.apply(new AzureRepository.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link GcsRepository gcs} {@code Repository} + * variant. + */ + public static GcsRepository.Builder gcs() { + return new GcsRepository.Builder(); + } + + /** + * Creates a Repository of the {@link GcsRepository gcs} {@code Repository} + * variant. + */ + public static Repository gcs(Function> fn) { + Repository.Builder builder = new Repository.Builder(); + builder.gcs(fn.apply(new GcsRepository.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link ReadOnlyUrlRepository url} + * {@code Repository} variant. + */ + public static ReadOnlyUrlRepository.Builder url() { + return new ReadOnlyUrlRepository.Builder(); + } + + /** + * Creates a Repository of the {@link ReadOnlyUrlRepository url} + * {@code Repository} variant. + */ + public static Repository url(Function> fn) { + Repository.Builder builder = new Repository.Builder(); + builder.url(fn.apply(new ReadOnlyUrlRepository.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link S3Repository s3} {@code Repository} variant. + */ + public static S3Repository.Builder s3() { + return new S3Repository.Builder(); + } + + /** + * Creates a Repository of the {@link S3Repository s3} {@code Repository} + * variant. + */ + public static Repository s3(Function> fn) { + Repository.Builder builder = new Repository.Builder(); + builder.s3(fn.apply(new S3Repository.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link SharedFileSystemRepository fs} + * {@code Repository} variant. + */ + public static SharedFileSystemRepository.Builder fs() { + return new SharedFileSystemRepository.Builder(); + } + + /** + * Creates a Repository of the {@link SharedFileSystemRepository fs} + * {@code Repository} variant. + */ + public static Repository fs( + Function> fn) { + Repository.Builder builder = new Repository.Builder(); + builder.fs(fn.apply(new SharedFileSystemRepository.Builder()).build()); + return builder.build(); + } + + /** + * Creates a builder for the {@link SourceOnlyRepository source} + * {@code Repository} variant. + */ + public static SourceOnlyRepository.Builder source() { + return new SourceOnlyRepository.Builder(); + } + + /** + * Creates a Repository of the {@link SourceOnlyRepository source} + * {@code Repository} variant. + */ + public static Repository source(Function> fn) { + Repository.Builder builder = new Repository.Builder(); + builder.source(fn.apply(new SourceOnlyRepository.Builder()).build()); + return builder.build(); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositorySettingsBase.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositorySettingsBase.java new file mode 100644 index 000000000..772913e94 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositorySettingsBase.java @@ -0,0 +1,220 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.JsonpSerializable; +import co.elastic.clients.json.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.String; +import java.util.Objects; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.RepositorySettingsBase + +/** + * + * @see API + * specification + */ + +public abstract class RepositorySettingsBase implements JsonpSerializable { + @Nullable + private final String chunkSize; + + @Nullable + private final Boolean compress; + + @Nullable + private final String maxRestoreBytesPerSec; + + @Nullable + private final String maxSnapshotBytesPerSec; + + // --------------------------------------------------------------------------------------------- + + protected RepositorySettingsBase(AbstractBuilder builder) { + + this.chunkSize = builder.chunkSize; + this.compress = builder.compress; + this.maxRestoreBytesPerSec = builder.maxRestoreBytesPerSec; + this.maxSnapshotBytesPerSec = builder.maxSnapshotBytesPerSec; + + } + + /** + * API name: {@code chunk_size} + */ + @Nullable + public final String chunkSize() { + return this.chunkSize; + } + + /** + * API name: {@code compress} + */ + @Nullable + public final Boolean compress() { + return this.compress; + } + + /** + * API name: {@code max_restore_bytes_per_sec} + */ + @Nullable + public final String maxRestoreBytesPerSec() { + return this.maxRestoreBytesPerSec; + } + + /** + * API name: {@code max_snapshot_bytes_per_sec} + */ + @Nullable + public final String maxSnapshotBytesPerSec() { + return this.maxSnapshotBytesPerSec; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.chunkSize != null) { + generator.writeKey("chunk_size"); + generator.write(this.chunkSize); + + } + if (this.compress != null) { + generator.writeKey("compress"); + generator.write(this.compress); + + } + if (this.maxRestoreBytesPerSec != null) { + generator.writeKey("max_restore_bytes_per_sec"); + generator.write(this.maxRestoreBytesPerSec); + + } + if (this.maxSnapshotBytesPerSec != null) { + generator.writeKey("max_snapshot_bytes_per_sec"); + generator.write(this.maxSnapshotBytesPerSec); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + public abstract static class AbstractBuilder> + extends + WithJsonObjectBuilderBase { + @Nullable + private String chunkSize; + + @Nullable + private Boolean compress; + + @Nullable + private String maxRestoreBytesPerSec; + + @Nullable + private String maxSnapshotBytesPerSec; + + /** + * API name: {@code chunk_size} + */ + public final BuilderT chunkSize(@Nullable String value) { + this.chunkSize = value; + return self(); + } + + /** + * API name: {@code compress} + */ + public final BuilderT compress(@Nullable Boolean value) { + this.compress = value; + return self(); + } + + /** + * API name: {@code max_restore_bytes_per_sec} + */ + public final BuilderT maxRestoreBytesPerSec(@Nullable String value) { + this.maxRestoreBytesPerSec = value; + return self(); + } + + /** + * API name: {@code max_snapshot_bytes_per_sec} + */ + public final BuilderT maxSnapshotBytesPerSec(@Nullable String value) { + this.maxSnapshotBytesPerSec = value; + return self(); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupRepositorySettingsBaseDeserializer( + ObjectDeserializer op) { + + op.add(AbstractBuilder::chunkSize, JsonpDeserializer.stringDeserializer(), "chunk_size"); + op.add(AbstractBuilder::compress, JsonpDeserializer.booleanDeserializer(), "compress"); + op.add(AbstractBuilder::maxRestoreBytesPerSec, JsonpDeserializer.stringDeserializer(), + "max_restore_bytes_per_sec"); + op.add(AbstractBuilder::maxSnapshotBytesPerSec, JsonpDeserializer.stringDeserializer(), + "max_snapshot_bytes_per_sec"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryVariant.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryVariant.java new file mode 100644 index 000000000..1ac913457 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/RepositoryVariant.java @@ -0,0 +1,50 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpSerializable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +/** + * Base interface for {@link Repository} variants. + */ +public interface RepositoryVariant extends JsonpSerializable { + + Repository.Kind _repositoryKind(); + + default Repository _toRepository() { + return new Repository(this); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/S3Repository.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/S3Repository.java new file mode 100644 index 000000000..8e8e359a3 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/S3Repository.java @@ -0,0 +1,154 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.S3Repository + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class S3Repository extends RepositoryBase implements RepositoryVariant { + private final S3RepositorySettings settings; + + // --------------------------------------------------------------------------------------------- + + private S3Repository(Builder builder) { + super(builder); + + this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); + + } + + public static S3Repository of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Repository variant kind. + */ + @Override + public Repository.Kind _repositoryKind() { + return Repository.Kind.S3; + } + + /** + * Required - API name: {@code settings} + */ + public final S3RepositorySettings settings() { + return this.settings; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "s3"); + super.serializeInternal(generator, mapper); + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link S3Repository}. + */ + + public static class Builder extends RepositoryBase.AbstractBuilder implements ObjectBuilder { + private S3RepositorySettings settings; + + /** + * Required - API name: {@code settings} + */ + public final Builder settings(S3RepositorySettings value) { + this.settings = value; + return this; + } + + /** + * Required - API name: {@code settings} + */ + public final Builder settings(Function> fn) { + return this.settings(fn.apply(new S3RepositorySettings.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link S3Repository}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public S3Repository build() { + _checkSingleUse(); + + return new S3Repository(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link S3Repository} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + S3Repository::setupS3RepositoryDeserializer); + + protected static void setupS3RepositoryDeserializer(ObjectDeserializer op) { + RepositoryBase.setupRepositoryBaseDeserializer(op); + op.add(Builder::settings, S3RepositorySettings._DESERIALIZER, "settings"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/S3RepositorySettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/S3RepositorySettings.java new file mode 100644 index 000000000..3b1b6928c --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/S3RepositorySettings.java @@ -0,0 +1,346 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.S3RepositorySettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class S3RepositorySettings extends RepositorySettingsBase { + private final String bucket; + + @Nullable + private final String client; + + @Nullable + private final String basePath; + + @Nullable + private final Boolean readonly; + + @Nullable + private final Boolean serverSideEncryption; + + @Nullable + private final String bufferSize; + + @Nullable + private final String cannedAcl; + + @Nullable + private final String storageClass; + + // --------------------------------------------------------------------------------------------- + + private S3RepositorySettings(Builder builder) { + super(builder); + + this.bucket = ApiTypeHelper.requireNonNull(builder.bucket, this, "bucket"); + this.client = builder.client; + this.basePath = builder.basePath; + this.readonly = builder.readonly; + this.serverSideEncryption = builder.serverSideEncryption; + this.bufferSize = builder.bufferSize; + this.cannedAcl = builder.cannedAcl; + this.storageClass = builder.storageClass; + + } + + public static S3RepositorySettings of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code bucket} + */ + public final String bucket() { + return this.bucket; + } + + /** + * API name: {@code client} + */ + @Nullable + public final String client() { + return this.client; + } + + /** + * API name: {@code base_path} + */ + @Nullable + public final String basePath() { + return this.basePath; + } + + /** + * API name: {@code readonly} + */ + @Nullable + public final Boolean readonly() { + return this.readonly; + } + + /** + * API name: {@code server_side_encryption} + */ + @Nullable + public final Boolean serverSideEncryption() { + return this.serverSideEncryption; + } + + /** + * API name: {@code buffer_size} + */ + @Nullable + public final String bufferSize() { + return this.bufferSize; + } + + /** + * API name: {@code canned_acl} + */ + @Nullable + public final String cannedAcl() { + return this.cannedAcl; + } + + /** + * API name: {@code storage_class} + */ + @Nullable + public final String storageClass() { + return this.storageClass; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + generator.writeKey("bucket"); + generator.write(this.bucket); + + if (this.client != null) { + generator.writeKey("client"); + generator.write(this.client); + + } + if (this.basePath != null) { + generator.writeKey("base_path"); + generator.write(this.basePath); + + } + if (this.readonly != null) { + generator.writeKey("readonly"); + generator.write(this.readonly); + + } + if (this.serverSideEncryption != null) { + generator.writeKey("server_side_encryption"); + generator.write(this.serverSideEncryption); + + } + if (this.bufferSize != null) { + generator.writeKey("buffer_size"); + generator.write(this.bufferSize); + + } + if (this.cannedAcl != null) { + generator.writeKey("canned_acl"); + generator.write(this.cannedAcl); + + } + if (this.storageClass != null) { + generator.writeKey("storage_class"); + generator.write(this.storageClass); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link S3RepositorySettings}. + */ + + public static class Builder extends RepositorySettingsBase.AbstractBuilder + implements + ObjectBuilder { + private String bucket; + + @Nullable + private String client; + + @Nullable + private String basePath; + + @Nullable + private Boolean readonly; + + @Nullable + private Boolean serverSideEncryption; + + @Nullable + private String bufferSize; + + @Nullable + private String cannedAcl; + + @Nullable + private String storageClass; + + /** + * Required - API name: {@code bucket} + */ + public final Builder bucket(String value) { + this.bucket = value; + return this; + } + + /** + * API name: {@code client} + */ + public final Builder client(@Nullable String value) { + this.client = value; + return this; + } + + /** + * API name: {@code base_path} + */ + public final Builder basePath(@Nullable String value) { + this.basePath = value; + return this; + } + + /** + * API name: {@code readonly} + */ + public final Builder readonly(@Nullable Boolean value) { + this.readonly = value; + return this; + } + + /** + * API name: {@code server_side_encryption} + */ + public final Builder serverSideEncryption(@Nullable Boolean value) { + this.serverSideEncryption = value; + return this; + } + + /** + * API name: {@code buffer_size} + */ + public final Builder bufferSize(@Nullable String value) { + this.bufferSize = value; + return this; + } + + /** + * API name: {@code canned_acl} + */ + public final Builder cannedAcl(@Nullable String value) { + this.cannedAcl = value; + return this; + } + + /** + * API name: {@code storage_class} + */ + public final Builder storageClass(@Nullable String value) { + this.storageClass = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link S3RepositorySettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public S3RepositorySettings build() { + _checkSingleUse(); + + return new S3RepositorySettings(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link S3RepositorySettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, S3RepositorySettings::setupS3RepositorySettingsDeserializer); + + protected static void setupS3RepositorySettingsDeserializer(ObjectDeserializer op) { + RepositorySettingsBase.setupRepositorySettingsBaseDeserializer(op); + op.add(Builder::bucket, JsonpDeserializer.stringDeserializer(), "bucket"); + op.add(Builder::client, JsonpDeserializer.stringDeserializer(), "client"); + op.add(Builder::basePath, JsonpDeserializer.stringDeserializer(), "base_path"); + op.add(Builder::readonly, JsonpDeserializer.booleanDeserializer(), "readonly"); + op.add(Builder::serverSideEncryption, JsonpDeserializer.booleanDeserializer(), "server_side_encryption"); + op.add(Builder::bufferSize, JsonpDeserializer.stringDeserializer(), "buffer_size"); + op.add(Builder::cannedAcl, JsonpDeserializer.stringDeserializer(), "canned_acl"); + op.add(Builder::storageClass, JsonpDeserializer.stringDeserializer(), "storage_class"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SharedFileSystemRepository.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SharedFileSystemRepository.java new file mode 100644 index 000000000..03ba8f085 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SharedFileSystemRepository.java @@ -0,0 +1,159 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.SharedFileSystemRepository + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class SharedFileSystemRepository extends RepositoryBase implements RepositoryVariant { + private final SharedFileSystemRepositorySettings settings; + + // --------------------------------------------------------------------------------------------- + + private SharedFileSystemRepository(Builder builder) { + super(builder); + + this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); + + } + + public static SharedFileSystemRepository of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Repository variant kind. + */ + @Override + public Repository.Kind _repositoryKind() { + return Repository.Kind.Fs; + } + + /** + * Required - API name: {@code settings} + */ + public final SharedFileSystemRepositorySettings settings() { + return this.settings; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "fs"); + super.serializeInternal(generator, mapper); + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link SharedFileSystemRepository}. + */ + + public static class Builder extends RepositoryBase.AbstractBuilder + implements + ObjectBuilder { + private SharedFileSystemRepositorySettings settings; + + /** + * Required - API name: {@code settings} + */ + public final Builder settings(SharedFileSystemRepositorySettings value) { + this.settings = value; + return this; + } + + /** + * Required - API name: {@code settings} + */ + public final Builder settings( + Function> fn) { + return this.settings(fn.apply(new SharedFileSystemRepositorySettings.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link SharedFileSystemRepository}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public SharedFileSystemRepository build() { + _checkSingleUse(); + + return new SharedFileSystemRepository(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SharedFileSystemRepository} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, SharedFileSystemRepository::setupSharedFileSystemRepositoryDeserializer); + + protected static void setupSharedFileSystemRepositoryDeserializer( + ObjectDeserializer op) { + RepositoryBase.setupRepositoryBaseDeserializer(op); + op.add(Builder::settings, SharedFileSystemRepositorySettings._DESERIALIZER, "settings"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SharedFileSystemRepositorySettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SharedFileSystemRepositorySettings.java new file mode 100644 index 000000000..dfe78cebc --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SharedFileSystemRepositorySettings.java @@ -0,0 +1,205 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.Integer; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.SharedFileSystemRepositorySettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class SharedFileSystemRepositorySettings extends RepositorySettingsBase { + private final String location; + + @Nullable + private final Integer maxNumberOfSnapshots; + + @Nullable + private final Boolean readonly; + + // --------------------------------------------------------------------------------------------- + + private SharedFileSystemRepositorySettings(Builder builder) { + super(builder); + + this.location = ApiTypeHelper.requireNonNull(builder.location, this, "location"); + this.maxNumberOfSnapshots = builder.maxNumberOfSnapshots; + this.readonly = builder.readonly; + + } + + public static SharedFileSystemRepositorySettings of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code location} + */ + public final String location() { + return this.location; + } + + /** + * API name: {@code max_number_of_snapshots} + */ + @Nullable + public final Integer maxNumberOfSnapshots() { + return this.maxNumberOfSnapshots; + } + + /** + * API name: {@code readonly} + */ + @Nullable + public final Boolean readonly() { + return this.readonly; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + generator.writeKey("location"); + generator.write(this.location); + + if (this.maxNumberOfSnapshots != null) { + generator.writeKey("max_number_of_snapshots"); + generator.write(this.maxNumberOfSnapshots); + + } + if (this.readonly != null) { + generator.writeKey("readonly"); + generator.write(this.readonly); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link SharedFileSystemRepositorySettings}. + */ + + public static class Builder extends RepositorySettingsBase.AbstractBuilder + implements + ObjectBuilder { + private String location; + + @Nullable + private Integer maxNumberOfSnapshots; + + @Nullable + private Boolean readonly; + + /** + * Required - API name: {@code location} + */ + public final Builder location(String value) { + this.location = value; + return this; + } + + /** + * API name: {@code max_number_of_snapshots} + */ + public final Builder maxNumberOfSnapshots(@Nullable Integer value) { + this.maxNumberOfSnapshots = value; + return this; + } + + /** + * API name: {@code readonly} + */ + public final Builder readonly(@Nullable Boolean value) { + this.readonly = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link SharedFileSystemRepositorySettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public SharedFileSystemRepositorySettings build() { + _checkSingleUse(); + + return new SharedFileSystemRepositorySettings(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SharedFileSystemRepositorySettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, + SharedFileSystemRepositorySettings::setupSharedFileSystemRepositorySettingsDeserializer); + + protected static void setupSharedFileSystemRepositorySettingsDeserializer( + ObjectDeserializer op) { + RepositorySettingsBase.setupRepositorySettingsBaseDeserializer(op); + op.add(Builder::location, JsonpDeserializer.stringDeserializer(), "location"); + op.add(Builder::maxNumberOfSnapshots, JsonpDeserializer.integerDeserializer(), "max_number_of_snapshots"); + op.add(Builder::readonly, JsonpDeserializer.booleanDeserializer(), "readonly"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SourceOnlyRepository.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SourceOnlyRepository.java new file mode 100644 index 000000000..97a29ae24 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SourceOnlyRepository.java @@ -0,0 +1,158 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.SourceOnlyRepository + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class SourceOnlyRepository extends RepositoryBase implements RepositoryVariant { + private final SourceOnlyRepositorySettings settings; + + // --------------------------------------------------------------------------------------------- + + private SourceOnlyRepository(Builder builder) { + super(builder); + + this.settings = ApiTypeHelper.requireNonNull(builder.settings, this, "settings"); + + } + + public static SourceOnlyRepository of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Repository variant kind. + */ + @Override + public Repository.Kind _repositoryKind() { + return Repository.Kind.Source; + } + + /** + * Required - API name: {@code settings} + */ + public final SourceOnlyRepositorySettings settings() { + return this.settings; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "source"); + super.serializeInternal(generator, mapper); + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link SourceOnlyRepository}. + */ + + public static class Builder extends RepositoryBase.AbstractBuilder + implements + ObjectBuilder { + private SourceOnlyRepositorySettings settings; + + /** + * Required - API name: {@code settings} + */ + public final Builder settings(SourceOnlyRepositorySettings value) { + this.settings = value; + return this; + } + + /** + * Required - API name: {@code settings} + */ + public final Builder settings( + Function> fn) { + return this.settings(fn.apply(new SourceOnlyRepositorySettings.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link SourceOnlyRepository}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public SourceOnlyRepository build() { + _checkSingleUse(); + + return new SourceOnlyRepository(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SourceOnlyRepository} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, SourceOnlyRepository::setupSourceOnlyRepositoryDeserializer); + + protected static void setupSourceOnlyRepositoryDeserializer(ObjectDeserializer op) { + RepositoryBase.setupRepositoryBaseDeserializer(op); + op.add(Builder::settings, SourceOnlyRepositorySettings._DESERIALIZER, "settings"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SourceOnlyRepositorySettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SourceOnlyRepositorySettings.java new file mode 100644 index 000000000..9230140c0 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/snapshot/SourceOnlyRepositorySettings.java @@ -0,0 +1,207 @@ +/* + * 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. + */ + +package co.elastic.clients.elasticsearch.snapshot; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.Integer; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: snapshot._types.SourceOnlyRepositorySettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class SourceOnlyRepositorySettings extends RepositorySettingsBase { + @Nullable + private final String delegateType; + + @Nullable + private final Integer maxNumberOfSnapshots; + + @Nullable + private final Boolean readOnly; + + // --------------------------------------------------------------------------------------------- + + private SourceOnlyRepositorySettings(Builder builder) { + super(builder); + + this.delegateType = builder.delegateType; + this.maxNumberOfSnapshots = builder.maxNumberOfSnapshots; + this.readOnly = builder.readOnly; + + } + + public static SourceOnlyRepositorySettings of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code delegate_type} + */ + @Nullable + public final String delegateType() { + return this.delegateType; + } + + /** + * API name: {@code max_number_of_snapshots} + */ + @Nullable + public final Integer maxNumberOfSnapshots() { + return this.maxNumberOfSnapshots; + } + + /** + * API name: {@code read_only} + */ + @Nullable + public final Boolean readOnly() { + return this.readOnly; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + if (this.delegateType != null) { + generator.writeKey("delegate_type"); + generator.write(this.delegateType); + + } + if (this.maxNumberOfSnapshots != null) { + generator.writeKey("max_number_of_snapshots"); + generator.write(this.maxNumberOfSnapshots); + + } + if (this.readOnly != null) { + generator.writeKey("read_only"); + generator.write(this.readOnly); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link SourceOnlyRepositorySettings}. + */ + + public static class Builder extends RepositorySettingsBase.AbstractBuilder + implements + ObjectBuilder { + @Nullable + private String delegateType; + + @Nullable + private Integer maxNumberOfSnapshots; + + @Nullable + private Boolean readOnly; + + /** + * API name: {@code delegate_type} + */ + public final Builder delegateType(@Nullable String value) { + this.delegateType = value; + return this; + } + + /** + * API name: {@code max_number_of_snapshots} + */ + public final Builder maxNumberOfSnapshots(@Nullable Integer value) { + this.maxNumberOfSnapshots = value; + return this; + } + + /** + * API name: {@code read_only} + */ + public final Builder readOnly(@Nullable Boolean value) { + this.readOnly = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link SourceOnlyRepositorySettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public SourceOnlyRepositorySettings build() { + _checkSingleUse(); + + return new SourceOnlyRepositorySettings(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SourceOnlyRepositorySettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, SourceOnlyRepositorySettings::setupSourceOnlyRepositorySettingsDeserializer); + + protected static void setupSourceOnlyRepositorySettingsDeserializer( + ObjectDeserializer op) { + RepositorySettingsBase.setupRepositorySettingsBaseDeserializer(op); + op.add(Builder::delegateType, JsonpDeserializer.stringDeserializer(), "delegate_type"); + op.add(Builder::maxNumberOfSnapshots, JsonpDeserializer.integerDeserializer(), "max_number_of_snapshots"); + op.add(Builder::readOnly, JsonpDeserializer.booleanDeserializer(), "read_only", "readonly"); + + } + +}