From b9c12fbf280a5b0f58e793a56359cf339b406d33 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Fri, 17 May 2024 13:36:33 +0200 Subject: [PATCH 1/2] Fix value body request serialization (descriptors) --- .../Api/IndexManagement/PutIndicesSettingsRequest.g.cs | 2 ++ .../_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs | 2 ++ .../_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs | 1 + .../_Generated/Api/IndexManagement/DownsampleRequest.g.cs | 2 ++ .../Api/IndexManagement/PutIndicesSettingsRequest.g.cs | 2 ++ .../_Generated/Api/Inference/PutModelRequest.g.cs | 1 + .../_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs | 2 ++ .../Api/SearchApplication/PutSearchApplicationRequest.g.cs | 1 + .../_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs | 1 + 9 files changed, 14 insertions(+) diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs index 061b7c36919..3958734ed41 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs @@ -194,6 +194,7 @@ public PutIndicesSettingsRequestDescriptor Settings(Action Detector(Action Config(Action Settings(Action Detector(Action Date: Tue, 28 May 2024 12:23:15 +0200 Subject: [PATCH 2/2] Fix value body request serialization (requests) --- .../_Generated/Api/CreateRequest.g.cs | 7 ++- .../PutIndicesSettingsRequest.g.cs | 7 ++- .../_Generated/Api/IndexRequest.g.cs | 7 ++- .../ValidateDetectorRequest.g.cs | 7 ++- .../Api/Snapshot/CreateRepositoryRequest.g.cs | 7 ++- .../Api/CreateRequest.cs | 12 +---- .../Api/IndexRequest.cs | 14 +---- .../CustomJsonWriterConverter.cs | 28 ---------- .../CustomJsonWriterConverterFactory.cs | 52 ------------------- .../DefaultRequestResponseSerializer.cs | 1 - .../Serialization/ICustomJsonWriter.cs | 17 ------ .../_Generated/Api/CreateRequest.g.cs | 7 ++- .../IndexManagement/DownsampleRequest.g.cs | 7 ++- .../PutIndicesSettingsRequest.g.cs | 7 ++- .../_Generated/Api/IndexRequest.g.cs | 7 ++- .../Api/Inference/PutModelRequest.g.cs | 7 ++- .../ValidateDetectorRequest.g.cs | 7 ++- .../PutSearchApplicationRequest.g.cs | 7 ++- .../Api/Snapshot/CreateRepositoryRequest.g.cs | 7 ++- 19 files changed, 81 insertions(+), 134 deletions(-) delete mode 100644 src/Elastic.Clients.Elasticsearch.Shared/Serialization/CustomJsonWriterConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch.Shared/Serialization/CustomJsonWriterConverterFactory.cs delete mode 100644 src/Elastic.Clients.Elasticsearch.Shared/Serialization/ICustomJsonWriter.cs diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateRequest.g.cs index 02dd0aaa5f0..ec2c0762f88 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateRequest.g.cs @@ -70,7 +70,7 @@ public sealed partial class CreateRequestParameters : RequestParameters /// /// Adds a JSON document to the specified data stream or index and makes it searchable.
If the target is an index and the document already exists, the request updates the document and increments its version.
///
-public sealed partial class CreateRequest : PlainRequest +public sealed partial class CreateRequest : PlainRequest, ISelfSerializable { public CreateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, Elastic.Clients.Elasticsearch.Serverless.Id id) : base(r => r.Required("index", index).Required("id", id)) { @@ -127,6 +127,11 @@ public CreateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E public Elastic.Clients.Elasticsearch.Serverless.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } [JsonIgnore] public TDocument Document { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + SourceSerialization.Serialize(Document, writer, settings.SourceSerializer); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs index 3958734ed41..346db16d225 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs @@ -70,7 +70,7 @@ public sealed partial class PutIndicesSettingsRequestParameters : RequestParamet /// /// Changes a dynamic index setting in real time. For data streams, index setting
changes are applied to all backing indices by default.
///
-public sealed partial class PutIndicesSettingsRequest : PlainRequest +public sealed partial class PutIndicesSettingsRequest : PlainRequest, ISelfSerializable { public PutIndicesSettingsRequest() { @@ -131,6 +131,11 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Serverless.Indice public Elastic.Clients.Elasticsearch.Serverless.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexSettings Settings { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + JsonSerializer.Serialize(writer, Settings, options); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexRequest.g.cs index b2903384440..0631106aec9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexRequest.g.cs @@ -90,7 +90,7 @@ public sealed partial class IndexRequestParameters : RequestParameters /// /// Adds a JSON document to the specified data stream or index and makes it searchable.
If the target is an index and the document already exists, the request updates the document and increments its version.
///
-public sealed partial class IndexRequest : PlainRequest +public sealed partial class IndexRequest : PlainRequest, ISelfSerializable { public IndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, Elastic.Clients.Elasticsearch.Serverless.Id? id) : base(r => r.Required("index", index).Optional("id", id)) { @@ -175,6 +175,11 @@ public IndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index) : public Elastic.Clients.Elasticsearch.Serverless.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } [JsonIgnore] public TDocument Document { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + SourceSerialization.Serialize(Document, writer, settings.SourceSerializer); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs index e64a5dbbba8..7b25c48799c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs @@ -36,7 +36,7 @@ public sealed partial class ValidateDetectorRequestParameters : RequestParameter /// /// Validates an anomaly detection detector. /// -public sealed partial class ValidateDetectorRequest : PlainRequest +public sealed partial class ValidateDetectorRequest : PlainRequest, ISelfSerializable { internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningValidateDetector; @@ -48,6 +48,11 @@ public sealed partial class ValidateDetectorRequest : PlainRequest diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs index c198cf68e2d..fb499f54e47 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs @@ -50,7 +50,7 @@ public sealed partial class CreateRepositoryRequestParameters : RequestParameter /// /// Creates a repository. /// -public sealed partial class CreateRepositoryRequest : PlainRequest +public sealed partial class CreateRepositoryRequest : PlainRequest, ISelfSerializable { public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Serverless.Name name) : base(r => r.Required("repository", name)) { @@ -83,6 +83,11 @@ public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Serverless.Name nam public bool? Verify { get => Q("verify"); set => Q("verify", value); } [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Snapshot.IRepository Repository { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + JsonSerializer.Serialize(writer, Repository, options); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Shared/Api/CreateRequest.cs b/src/Elastic.Clients.Elasticsearch.Shared/Api/CreateRequest.cs index b2d68e979e0..0adcab0935c 100644 --- a/src/Elastic.Clients.Elasticsearch.Shared/Api/CreateRequest.cs +++ b/src/Elastic.Clients.Elasticsearch.Shared/Api/CreateRequest.cs @@ -2,21 +2,13 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -#if ELASTICSEARCH_SERVERLESS -using Elastic.Clients.Elasticsearch.Serverless.Serialization; -#else -using Elastic.Clients.Elasticsearch.Serialization; -#endif -using Elastic.Transport; -using System.Text.Json; - #if ELASTICSEARCH_SERVERLESS namespace Elastic.Clients.Elasticsearch.Serverless; #else namespace Elastic.Clients.Elasticsearch; #endif -public sealed partial class CreateRequest : ICustomJsonWriter +public sealed partial class CreateRequest { public CreateRequest(Id id) : this(typeof(TDocument), id) @@ -26,6 +18,4 @@ public CreateRequest(Id id) : this(typeof(TDocument), id) public CreateRequest(TDocument documentWithId, IndexName index = null, Id id = null) : this(index ?? typeof(TDocument), id ?? Id.From(documentWithId)) => Document = documentWithId; - - public void WriteJson(Utf8JsonWriter writer, Serializer sourceSerializer) => SourceSerialization.Serialize(Document, writer, sourceSerializer); } diff --git a/src/Elastic.Clients.Elasticsearch.Shared/Api/IndexRequest.cs b/src/Elastic.Clients.Elasticsearch.Shared/Api/IndexRequest.cs index 90d5d8ae558..731ae90bfcb 100644 --- a/src/Elastic.Clients.Elasticsearch.Shared/Api/IndexRequest.cs +++ b/src/Elastic.Clients.Elasticsearch.Shared/Api/IndexRequest.cs @@ -2,18 +2,12 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Text.Json; using System.Text.Json.Serialization; #if ELASTICSEARCH_SERVERLESS using Elastic.Clients.Elasticsearch.Serverless.Requests; #else using Elastic.Clients.Elasticsearch.Requests; #endif -#if ELASTICSEARCH_SERVERLESS -using Elastic.Clients.Elasticsearch.Serverless.Serialization; -#else -using Elastic.Clients.Elasticsearch.Serialization; -#endif using Elastic.Transport; #if ELASTICSEARCH_SERVERLESS @@ -22,7 +16,7 @@ namespace Elastic.Clients.Elasticsearch.Serverless; namespace Elastic.Clients.Elasticsearch; #endif -public partial class IndexRequest : ICustomJsonWriter +public partial class IndexRequest { public IndexRequest() : this(typeof(TDocument)) { } @@ -36,17 +30,13 @@ public IndexRequest() : this(typeof(TDocument)) { } [JsonIgnore] private Id? Id => RouteValues.Get("id"); - void ICustomJsonWriter.WriteJson(Utf8JsonWriter writer, Serializer sourceSerializer) => SourceSerialization.Serialize(Document, writer, sourceSerializer); - internal static HttpMethod GetHttpMethod(IndexRequest request) => request.Id?.StringOrLongValue != null || request.RouteValues.ContainsId ? HttpMethod.PUT : HttpMethod.POST; } -public sealed partial class IndexRequestDescriptor : ICustomJsonWriter +public sealed partial class IndexRequestDescriptor { internal Id _id; - public void WriteJson(Utf8JsonWriter writer, Serializer sourceSerializer) => SourceSerialization.Serialize(DocumentValue, writer, sourceSerializer); - protected override HttpMethod? DynamicHttpMethod => _id is not null || RouteValues.ContainsId ? HttpMethod.PUT : HttpMethod.POST; } diff --git a/src/Elastic.Clients.Elasticsearch.Shared/Serialization/CustomJsonWriterConverter.cs b/src/Elastic.Clients.Elasticsearch.Shared/Serialization/CustomJsonWriterConverter.cs deleted file mode 100644 index f7ff0ed0f86..00000000000 --- a/src/Elastic.Clients.Elasticsearch.Shared/Serialization/CustomJsonWriterConverter.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -#if ELASTICSEARCH_SERVERLESS -namespace Elastic.Clients.Elasticsearch.Serverless.Serialization; -#else -namespace Elastic.Clients.Elasticsearch.Serialization; -#endif - -internal sealed class CustomJsonWriterConverter : JsonConverter -{ - private readonly IElasticsearchClientSettings _settings; - - public CustomJsonWriterConverter(IElasticsearchClientSettings settings) => _settings = settings; - - public override TDocument? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => - throw new NotImplementedException(); - - public override void Write(Utf8JsonWriter writer, TDocument value, JsonSerializerOptions options) - { - if (value is ICustomJsonWriter proxyRequest) proxyRequest.WriteJson(writer, _settings.SourceSerializer); - } -} diff --git a/src/Elastic.Clients.Elasticsearch.Shared/Serialization/CustomJsonWriterConverterFactory.cs b/src/Elastic.Clients.Elasticsearch.Shared/Serialization/CustomJsonWriterConverterFactory.cs deleted file mode 100644 index 5f9913fabe2..00000000000 --- a/src/Elastic.Clients.Elasticsearch.Shared/Serialization/CustomJsonWriterConverterFactory.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Reflection; -using System.Text.Json; -using System.Text.Json.Serialization; - -#if ELASTICSEARCH_SERVERLESS -namespace Elastic.Clients.Elasticsearch.Serverless.Serialization; -#else -namespace Elastic.Clients.Elasticsearch.Serialization; -#endif - -internal sealed class CustomJsonWriterConverterFactory : JsonConverterFactory -{ - private readonly IElasticsearchClientSettings _settings; - - public CustomJsonWriterConverterFactory(IElasticsearchClientSettings settings) => _settings = settings; - - public override bool CanConvert(Type typeToConvert) - { - if (!typeToConvert.IsGenericType) - return false; - - var interfaces = typeToConvert.GetInterfaces(); - - var canConvert = false; - - foreach (var item in interfaces) - { - var type = item.UnderlyingSystemType; - if (type == typeof(ICustomJsonWriter)) - canConvert = true; - } - - return canConvert; - } - - public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options) - { - var converter = (JsonConverter)Activator.CreateInstance( - typeof(CustomJsonWriterConverter<>).MakeGenericType(typeToConvert), - BindingFlags.Instance | BindingFlags.Public, - args: new object[] { _settings }, - binder: null, - culture: null)!; - - return converter; - } -} diff --git a/src/Elastic.Clients.Elasticsearch.Shared/Serialization/DefaultRequestResponseSerializer.cs b/src/Elastic.Clients.Elasticsearch.Shared/Serialization/DefaultRequestResponseSerializer.cs index 6ae3aff7bf2..3d497c3c25e 100644 --- a/src/Elastic.Clients.Elasticsearch.Shared/Serialization/DefaultRequestResponseSerializer.cs +++ b/src/Elastic.Clients.Elasticsearch.Shared/Serialization/DefaultRequestResponseSerializer.cs @@ -35,7 +35,6 @@ public DefaultRequestResponseSerializer(IElasticsearchClientSettings settings) : new KeyValuePairConverterFactory(settings), new ObjectToInferredTypesConverter(), new SourceConverterFactory(settings), - new CustomJsonWriterConverterFactory(settings), new SelfSerializableConverterFactory(settings), new SelfDeserializableConverterFactory(settings), new SelfTwoWaySerializableConverterFactory(settings), diff --git a/src/Elastic.Clients.Elasticsearch.Shared/Serialization/ICustomJsonWriter.cs b/src/Elastic.Clients.Elasticsearch.Shared/Serialization/ICustomJsonWriter.cs deleted file mode 100644 index d64a10f4cb1..00000000000 --- a/src/Elastic.Clients.Elasticsearch.Shared/Serialization/ICustomJsonWriter.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System.Text.Json; -using Elastic.Transport; - -#if ELASTICSEARCH_SERVERLESS -namespace Elastic.Clients.Elasticsearch.Serverless.Serialization; -#else -namespace Elastic.Clients.Elasticsearch.Serialization; -#endif - -internal interface ICustomJsonWriter -{ - void WriteJson(Utf8JsonWriter writer, Serializer sourceSerializer); -} diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs index 710c8e581cc..3612077da45 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs @@ -70,7 +70,7 @@ public sealed partial class CreateRequestParameters : RequestParameters /// /// Adds a JSON document to the specified data stream or index and makes it searchable.
If the target is an index and the document already exists, the request updates the document and increments its version.
///
-public sealed partial class CreateRequest : PlainRequest +public sealed partial class CreateRequest : PlainRequest, ISelfSerializable { public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("index", index).Required("id", id)) { @@ -127,6 +127,11 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } [JsonIgnore] public TDocument Document { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + SourceSerialization.Serialize(Document, writer, settings.SourceSerializer); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs index 640433b0610..47e14d6b8db 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs @@ -36,7 +36,7 @@ public sealed partial class DownsampleRequestParameters : RequestParameters /// /// Aggregates a time series (TSDS) index and stores pre-computed statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) for each metric field grouped by a configured time interval. /// -public sealed partial class DownsampleRequest : PlainRequest +public sealed partial class DownsampleRequest : PlainRequest, ISelfSerializable { public DownsampleRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.IndexName targetIndex) : base(r => r.Required("index", index).Required("target_index", targetIndex)) { @@ -52,6 +52,11 @@ public DownsampleRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic. [JsonIgnore] public Elastic.Clients.Elasticsearch.IndexManagement.DownsampleConfig Config { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + JsonSerializer.Serialize(writer, Config, options); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs index 1c6cd09bded..05d9d31d8d2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs @@ -70,7 +70,7 @@ public sealed partial class PutIndicesSettingsRequestParameters : RequestParamet /// /// Changes a dynamic index setting in real time. For data streams, index setting
changes are applied to all backing indices by default.
///
-public sealed partial class PutIndicesSettingsRequest : PlainRequest +public sealed partial class PutIndicesSettingsRequest : PlainRequest, ISelfSerializable { public PutIndicesSettingsRequest() { @@ -131,6 +131,11 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } [JsonIgnore] public Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings Settings { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + JsonSerializer.Serialize(writer, Settings, options); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs index 943c270409c..d58b30a3f3c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs @@ -90,7 +90,7 @@ public sealed partial class IndexRequestParameters : RequestParameters /// /// Adds a JSON document to the specified data stream or index and makes it searchable.
If the target is an index and the document already exists, the request updates the document and increments its version.
///
-public sealed partial class IndexRequest : PlainRequest +public sealed partial class IndexRequest : PlainRequest, ISelfSerializable { public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Required("index", index).Optional("id", id)) { @@ -175,6 +175,11 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } [JsonIgnore] public TDocument Document { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + SourceSerialization.Serialize(Document, writer, settings.SourceSerializer); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutModelRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutModelRequest.g.cs index 55f80bddf76..857ed069b7f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutModelRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutModelRequest.g.cs @@ -36,7 +36,7 @@ public sealed partial class PutModelRequestParameters : RequestParameters /// /// Create an inference service model /// -public sealed partial class PutModelRequest : PlainRequest +public sealed partial class PutModelRequest : PlainRequest, ISelfSerializable { public PutModelRequest(Elastic.Clients.Elasticsearch.Id inferenceId) : base(r => r.Required("inference_id", inferenceId)) { @@ -56,6 +56,11 @@ public PutModelRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTyp [JsonIgnore] public Elastic.Clients.Elasticsearch.Inference.ModelConfig ModelConfig { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + JsonSerializer.Serialize(writer, ModelConfig, options); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs index 10b9d89ddfb..6b6738b6e47 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs @@ -36,7 +36,7 @@ public sealed partial class ValidateDetectorRequestParameters : RequestParameter /// /// Validates an anomaly detection detector. /// -public sealed partial class ValidateDetectorRequest : PlainRequest +public sealed partial class ValidateDetectorRequest : PlainRequest, ISelfSerializable { internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningValidateDetector; @@ -48,6 +48,11 @@ public sealed partial class ValidateDetectorRequest : PlainRequest diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs index 685a16c339b..86a4f15dd1a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs @@ -40,7 +40,7 @@ public sealed partial class PutSearchApplicationRequestParameters : RequestParam /// /// Creates or updates a search application. /// -public sealed partial class PutSearchApplicationRequest : PlainRequest +public sealed partial class PutSearchApplicationRequest : PlainRequest, ISelfSerializable { public PutSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name)) { @@ -61,6 +61,11 @@ public PutSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : ba public bool? Create { get => Q("create"); set => Q("create", value); } [JsonIgnore] public Elastic.Clients.Elasticsearch.SearchApplication.SearchApplication SearchApplication { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + JsonSerializer.Serialize(writer, SearchApplication, options); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs index bf717e15ec8..e749c8f82a1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs @@ -50,7 +50,7 @@ public sealed partial class CreateRepositoryRequestParameters : RequestParameter /// /// Creates a repository. /// -public sealed partial class CreateRepositoryRequest : PlainRequest +public sealed partial class CreateRepositoryRequest : PlainRequest, ISelfSerializable { public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("repository", name)) { @@ -83,6 +83,11 @@ public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r public bool? Verify { get => Q("verify"); set => Q("verify", value); } [JsonIgnore] public Elastic.Clients.Elasticsearch.Snapshot.IRepository Repository { get; set; } + + void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + JsonSerializer.Serialize(writer, Repository, options); + } } ///