From ca431a216c0176447d1a0c1d2de9ecfd882afc64 Mon Sep 17 00:00:00 2001 From: Laura Trotta Date: Tue, 17 Dec 2024 18:48:49 +0100 Subject: [PATCH] nullable properties based on flavor availability --- .../ml/ModelSnapshotUpgrade.java | 13 +++-- .../clients/elasticsearch/nodes/Http.java | 3 +- .../GetBuiltinPrivilegesResponse.java | 3 +- .../elasticsearch/xpack/info/Features.java | 53 +++++++++++++------ 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/ModelSnapshotUpgrade.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/ModelSnapshotUpgrade.java index a694ee909..f8339aee5 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/ModelSnapshotUpgrade.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/ModelSnapshotUpgrade.java @@ -65,6 +65,7 @@ public class ModelSnapshotUpgrade implements JsonpSerializable { private final SnapshotUpgradeState state; + @Nullable private final DiscoveryNodeContent node; private final String assignmentExplanation; @@ -76,7 +77,7 @@ private ModelSnapshotUpgrade(Builder builder) { this.jobId = ApiTypeHelper.requireNonNull(builder.jobId, this, "jobId"); this.snapshotId = ApiTypeHelper.requireNonNull(builder.snapshotId, this, "snapshotId"); this.state = ApiTypeHelper.requireNonNull(builder.state, this, "state"); - this.node = ApiTypeHelper.requireNonNull(builder.node, this, "node"); + this.node = builder.node; this.assignmentExplanation = ApiTypeHelper.requireNonNull(builder.assignmentExplanation, this, "assignmentExplanation"); @@ -110,6 +111,7 @@ public final SnapshotUpgradeState state() { /** * Required - API name: {@code node} */ + @Nullable public final DiscoveryNodeContent node() { return this.node; } @@ -140,9 +142,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("state"); this.state.serialize(generator, mapper); - generator.writeKey("node"); - this.node.serialize(generator, mapper); + if (this.node != null) { + generator.writeKey("node"); + this.node.serialize(generator, mapper); + } generator.writeKey("assignment_explanation"); generator.write(this.assignmentExplanation); @@ -168,6 +172,7 @@ public static class Builder extends WithJsonObjectBuilderBase private SnapshotUpgradeState state; + @Nullable private DiscoveryNodeContent node; private String assignmentExplanation; @@ -199,7 +204,7 @@ public final Builder state(SnapshotUpgradeState value) { /** * Required - API name: {@code node} */ - public final Builder node(DiscoveryNodeContent value) { + public final Builder node(@Nullable DiscoveryNodeContent value) { this.node = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/Http.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/Http.java index 44533c0eb..7fba56526 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/Http.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/Http.java @@ -80,7 +80,7 @@ private Http(Builder builder) { this.currentOpen = builder.currentOpen; this.totalOpened = builder.totalOpened; this.clients = ApiTypeHelper.unmodifiable(builder.clients); - this.routes = ApiTypeHelper.unmodifiableRequired(builder.routes, this, "routes"); + this.routes = ApiTypeHelper.unmodifiable(builder.routes); } @@ -195,6 +195,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private List clients; + @Nullable private Map routes; /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetBuiltinPrivilegesResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetBuiltinPrivilegesResponse.java index 180893c5e..90836d7f0 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetBuiltinPrivilegesResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetBuiltinPrivilegesResponse.java @@ -73,7 +73,7 @@ private GetBuiltinPrivilegesResponse(Builder builder) { this.cluster = ApiTypeHelper.unmodifiableRequired(builder.cluster, this, "cluster"); this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index"); - this.remoteCluster = ApiTypeHelper.unmodifiableRequired(builder.remoteCluster, this, "remoteCluster"); + this.remoteCluster = ApiTypeHelper.unmodifiable(builder.remoteCluster); } @@ -163,6 +163,7 @@ public static class Builder extends WithJsonObjectBuilderBase private List index; + @Nullable private List remoteCluster; /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/info/Features.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/info/Features.java index c13fe9212..544b149e6 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/info/Features.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/xpack/info/Features.java @@ -70,10 +70,12 @@ public class Features implements JsonpSerializable { private final Feature enrich; + @Nullable private final Feature enterpriseSearch; private final Feature eql; + @Nullable private final Feature esql; private final Feature frozenIndices; @@ -107,12 +109,14 @@ public class Features implements JsonpSerializable { private final Feature transform; + @Nullable private final Feature universalProfiling; private final Feature votingOnly; private final Feature watcher; + @Nullable private final Feature archive; // --------------------------------------------------------------------------------------------- @@ -125,9 +129,9 @@ private Features(Builder builder) { this.dataStreams = ApiTypeHelper.requireNonNull(builder.dataStreams, this, "dataStreams"); this.dataTiers = ApiTypeHelper.requireNonNull(builder.dataTiers, this, "dataTiers"); this.enrich = ApiTypeHelper.requireNonNull(builder.enrich, this, "enrich"); - this.enterpriseSearch = ApiTypeHelper.requireNonNull(builder.enterpriseSearch, this, "enterpriseSearch"); + this.enterpriseSearch = builder.enterpriseSearch; this.eql = ApiTypeHelper.requireNonNull(builder.eql, this, "eql"); - this.esql = ApiTypeHelper.requireNonNull(builder.esql, this, "esql"); + this.esql = builder.esql; this.frozenIndices = ApiTypeHelper.requireNonNull(builder.frozenIndices, this, "frozenIndices"); this.graph = ApiTypeHelper.requireNonNull(builder.graph, this, "graph"); this.ilm = ApiTypeHelper.requireNonNull(builder.ilm, this, "ilm"); @@ -144,10 +148,10 @@ private Features(Builder builder) { this.spatial = ApiTypeHelper.requireNonNull(builder.spatial, this, "spatial"); this.sql = ApiTypeHelper.requireNonNull(builder.sql, this, "sql"); this.transform = ApiTypeHelper.requireNonNull(builder.transform, this, "transform"); - this.universalProfiling = ApiTypeHelper.requireNonNull(builder.universalProfiling, this, "universalProfiling"); + this.universalProfiling = builder.universalProfiling; this.votingOnly = ApiTypeHelper.requireNonNull(builder.votingOnly, this, "votingOnly"); this.watcher = ApiTypeHelper.requireNonNull(builder.watcher, this, "watcher"); - this.archive = ApiTypeHelper.requireNonNull(builder.archive, this, "archive"); + this.archive = builder.archive; } @@ -200,6 +204,7 @@ public final Feature enrich() { /** * Required - API name: {@code enterprise_search} */ + @Nullable public final Feature enterpriseSearch() { return this.enterpriseSearch; } @@ -214,6 +219,7 @@ public final Feature eql() { /** * Required - API name: {@code esql} */ + @Nullable public final Feature esql() { return this.esql; } @@ -327,6 +333,7 @@ public final Feature transform() { /** * Required - API name: {@code universal_profiling} */ + @Nullable public final Feature universalProfiling() { return this.universalProfiling; } @@ -348,6 +355,7 @@ public final Feature watcher() { /** * Required - API name: {@code archive} */ + @Nullable public final Feature archive() { return this.archive; } @@ -381,15 +389,19 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("enrich"); this.enrich.serialize(generator, mapper); - generator.writeKey("enterprise_search"); - this.enterpriseSearch.serialize(generator, mapper); + if (this.enterpriseSearch != null) { + generator.writeKey("enterprise_search"); + this.enterpriseSearch.serialize(generator, mapper); + } generator.writeKey("eql"); this.eql.serialize(generator, mapper); - generator.writeKey("esql"); - this.esql.serialize(generator, mapper); + if (this.esql != null) { + generator.writeKey("esql"); + this.esql.serialize(generator, mapper); + } generator.writeKey("frozen_indices"); this.frozenIndices.serialize(generator, mapper); @@ -437,17 +449,22 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("transform"); this.transform.serialize(generator, mapper); - generator.writeKey("universal_profiling"); - this.universalProfiling.serialize(generator, mapper); + if (this.universalProfiling != null) { + generator.writeKey("universal_profiling"); + this.universalProfiling.serialize(generator, mapper); + } generator.writeKey("voting_only"); this.votingOnly.serialize(generator, mapper); generator.writeKey("watcher"); this.watcher.serialize(generator, mapper); - generator.writeKey("archive"); - this.archive.serialize(generator, mapper); + if (this.archive != null) { + generator.writeKey("archive"); + this.archive.serialize(generator, mapper); + + } } @@ -475,10 +492,12 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Feature enrich; + @Nullable private Feature enterpriseSearch; private Feature eql; + @Nullable private Feature esql; private Feature frozenIndices; @@ -512,12 +531,14 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Feature transform; + @Nullable private Feature universalProfiling; private Feature votingOnly; private Feature watcher; + @Nullable private Feature archive; /** @@ -613,7 +634,7 @@ public final Builder enrich(Function> fn /** * Required - API name: {@code enterprise_search} */ - public final Builder enterpriseSearch(Feature value) { + public final Builder enterpriseSearch(@Nullable Feature value) { this.enterpriseSearch = value; return this; } @@ -643,7 +664,7 @@ public final Builder eql(Function> fn) { /** * Required - API name: {@code esql} */ - public final Builder esql(Feature value) { + public final Builder esql(@Nullable Feature value) { this.esql = value; return this; } @@ -883,7 +904,7 @@ public final Builder transform(Function> /** * Required - API name: {@code universal_profiling} */ - public final Builder universalProfiling(Feature value) { + public final Builder universalProfiling(@Nullable Feature value) { this.universalProfiling = value; return this; } @@ -928,7 +949,7 @@ public final Builder watcher(Function> f /** * Required - API name: {@code archive} */ - public final Builder archive(Feature value) { + public final Builder archive(@Nullable Feature value) { this.archive = value; return this; }